This article explains how to change the number of files that are displayed in the list of most recently used files that is displayed in the File menu.
How is it done?
In the class derived from
CWinApp in a SDI or MDI application created by the Application Wizard, there is an undocumented member
m_pRecentFileList. This is an object of the class
CRecentFileList. This is the class that is used to display the MRU files in the menu. The class does not provide anyway to change the size without deleting the class and recreating it. Below is the method that is used to accomplish this:
BOOL CMRUAppApp::ChangeMRUCount(UINT nCount)
BOOL bReturn = FALSE;
ASSERT(nCount <= 16);
CString strSection = m_pRecentFileList->m_strSectionName;
CString strEntryFormat = m_pRecentFileList->m_strEntryFormat;
m_pRecentFileList = new CRecentFileList(0, strSection, strEntryFormat, nCount);
bReturn = TRUE;
Points of interest
To be able to compile the code to use the
m_pRecentFileList object, you must include the header afxadv.h.
The first thing the method does is to store the section in the registry or application INI file where the MRU file list is stored and to get the string that is used to format the name of the entries stored in the registry. The current object is then deleted and a new one created using these stored values and the count of MRU files that was sent to the method. If this was created successfully then the list is read back from the registry or INI file.
You can only have a maximum of 16 items in the list.