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 ;

}

Subscribe / Share

It's very calm over here, why not leave a comment?

Leave a Reply




Categories

Powered by Yahoo! Answers