Opening the document from the top of the recent file list automatically.

How to make sure that the application automatically opens the document that is at the top of the recent file list?

Ans: #include the ‘afxadv.h’ file in the application class’s source file. This file is required for CRecentFileList class’s definition.  Add the following code in InitInstance( ) to open the first file in MRU list.

BOOL CMRUApp::InitInstance( )

{

// AppWizard generated code

if ( cmdInfo.m_nShellCommand == CCommandLineInfo::FileNew || cmdInfo.m_nShellCommand ==

CCommandLineInfo::FileNothing )

{

if ( m_pRecentFileList != NULL )

{

CString strmru = ( *m_pRecentFileList )[0] ;

if ( !strmru.IsEmpty( ) )

OpenDocumentFile ( strmru ) ;

}

}

else

if ( !ProcessShellCommand ( cmdInfo ) )

return FALSE ;

}

This entry was posted in VC++ and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>