Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 504745
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:31:39+00:00 2026-05-13T06:31:39+00:00

I would like to maintain a simple recent files list on my MFC application

  • 0

I would like to maintain a simple recent files list on my MFC application that shows the 4 most recently used file names.

I have been playing with an example from Eugene Kain’s “The MFC Answer Book” that can programmatically add strings to the Recent Files list for an application based on the standard Document/View architecture: (see “Managing the Recent Files List (MRU)”) :

http://www.nerdbooks.com/isbn/0201185377

My application is a fairly lightweight utility that does not use the Document/View architecture to manage data, file formats and so on. I am not sure if the same principles used in the above example would be applicable here.

Does anyone have any examples of how they go about maintaining a recent files list that is displayed in the File menu, and can be stored in a file / registry setting somewhere? More than anything, it’s my lack of knowledge and understanding that is holding me back.

Update: I have recently found this CodeProject article to be quite useful…

http://www.codeproject.com/KB/dialog/rfldlg.aspx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:31:39+00:00Added an answer on May 13, 2026 at 6:31 am

    I recently did that using MFC, so since you seems to be using MFC as well maybe it will help:

    in:

    BOOL MyApp::InitInstance()
    {
        // Call this member function from within the InitInstance member function to 
        // enable and load the list of most recently used (MRU) files and last preview 
        // state.
        SetRegistryKey("MyApp"); //I think this caused problem with Vista and up if it wasn't there
                                     //, not really sure now since I didn't wrote a comment at the time
        LoadStdProfileSettings();
    }
    

    //..

    //function called when you save or load a file
    void MyApp::addToRecentFileList(boost::filesystem::path const& path)
    {
        //use file_string to have your path in windows native format (\ instead of /)
        //or it won't work in the MFC version in vs2010 (error in CRecentFileList::Add at
        //hr = afxGlobalData.ShellCreateItemFromParsingName)
        AddToRecentFileList(path.file_string().c_str());
    }
    
    //function called when the user click on a recent file in the menu
    boost::filesystem::path MyApp::getRecentFile(int index) const
    {
        return std::string((*m_pRecentFileList)[index]);
    }
    

    //…

    //handler for the menu
    BOOL MyFrame::OnCommand(WPARAM wParam, LPARAM lParam)
    {
        BOOL answ = TRUE;
    
        if(wParam >= ID_FILE_MRU_FILE1 && wParam <= ID_FILE_MRU_FILE16)
        {
            int nIndex = wParam - ID_FILE_MRU_FILE1;
    
            boost::filesystem::path path = getApp()->getRecentFile(nIndex);
            //do something with the recent file, probably load it
    
            return answ;
        }
    }
    

    You only need that your application is derived from CWinApp (and I use a class derived from CFrameWnd to handle the menu, maybe you do the same?).

    Tell me if that works for you. Not sure if I have everything.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to create an auto increment function that allows me to maintain
Would like to make anapplication in Java that will not automatically parse parameters used
I have developed a small application that I would like to try and sell
I'm working on a side project that would be a simple web application to
I have a lot of different UserControls and would like to maintain consistent UI
I would like to know how I can maintain the scroll position when I
I would like to know if it is possible to maintain an authentication (like
Would like to get a list of advantages and disadvantages of using Stored Procedures.
I have a simple site to develop and would like to learn PHP as
A simple (one might think!) question to all CSS gurus: I would like to

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.