Click here to Skip to main content
12,755,332 members (40,496 online)
Click here to Skip to main content
Add your own
alternative version


19 bookmarked
Posted 9 Apr 2003

Changing the number of items that appear in the Most Recently Used List (MRU)

, 9 Apr 2003
Rate this:
Please Sign up or sign in to vote.
How to change the number of items that appear in the Most Recently Used List (MRU).


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:

#include <afxadv.h>        // This must be included for the CRecentFileList class

BOOL CMRUAppApp::ChangeMRUCount(UINT nCount)
    BOOL bReturn = FALSE;

    ASSERT(nCount <= 16);        // Make sure value is not greater than 16

    // Make sure that the list is written to registry


    // Get place in registry and format from original CRecentFileList

    CString strSection = m_pRecentFileList->m_strSectionName;
    CString strEntryFormat = m_pRecentFileList->m_strEntryFormat;

    // Delete current CRecentFileList

    delete m_pRecentFileList;

    // Create a new one 

    m_pRecentFileList = new CRecentFileList(0, strSection, strEntryFormat, nCount);


        bReturn = TRUE;

        // Reload list of MRU files from registry


    return bReturn;

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.


This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

A list of licenses authors might use can be found here


About the Author

Jason Walsh
Web Developer
United Kingdom United Kingdom
No Biography provided

You may also be interested in...


Comments and Discussions

GeneralMRU from Start button Pin
Vladimir Afanasyev10-Apr-03 21:26
memberVladimir Afanasyev10-Apr-03 21:26 
QuestionCWinApp::LoadStdProfileSettings? Pin
George10-Apr-03 21:07
memberGeorge10-Apr-03 21:07 
AnswerRe: CWinApp::LoadStdProfileSettings? Pin
eFotografo22-Sep-11 2:14
membereFotografo22-Sep-11 2:14 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web02 | 2.8.170217.1 | Last Updated 10 Apr 2003
Article Copyright 2003 by Jason Walsh
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid