Display the full path file name in the recent file list menu item
Author: Pablo Presedo ppresedo@hotmail.com
Recently, someone emails ask me how to use the MFC application to get the full path and file name in the previously opened file list. The default behavior is the full path only when the current directory is different from the directory of the file positioning. If it is too long, the signal will be shorter.
The file name displayed in the recent file list is created by the createfilelist :: getDisplayName function. This function is called by CRECENTFILELIST :: UpdateMenu, it is called by cwinapp :: ON- UpdateRECENTFILEMENU function call, CWINAPP :: OnUpdateREncentFileMenu function is called to respond to the update command.
ON_UPDATE_COMMAND_UI (ID_FILE_MRU_FILE1, ONUPDATERECENTFILEMENU) Appcore.cpp Inlet in the information map.
Void cwinapp :: onupdaterecentfilemenu (ccmdui * pcmdui)
{Assert_Valid (this); if (m_precentfilelist == null) // no MRU Files
// No MRU file
PCMDUI-> Enable (false); else
// *** this function will call getDisplayName. ***
// *** This function will call getDisplayName ***
M_PRECENTFILELIST-> UpdateMenu (PCMDUI);} One solution for this problem is to delete createFileList * m_precentfileList after derived to LoadStdProfileSettings in the cwinapp from InitInstance. We replace it with a class we have derived from CRECENTFILELIST (List 6). Our CRECENTFILIST will override the GetDisplayName function. Allegate the CRECENTFILIST derived class constructor parameter nsize to the parameter nmaxmru of LoadStdprofileSettings. That is all. In this month's code file file, I have included displaying this presentation example, and an example of how to display a recent file list with an MFC dialog application, as well. By default, the MFC dialog application does not support the recent file list.
George Frazier is a software engineer in the System Design and Verification group of Cadence Design Systems Inc, since 1991 has been writing a Windows program. You can contact your electronic mailbox georgefrazier@yahoo.com.