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

  • Home
  • SEARCH
  • 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

Ask A Question

Stats

  • Questions 297k
  • Answers 297k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer A nice approach for this is to use an attached… May 13, 2026 at 7:22 pm
  • Editorial Team
    Editorial Team added an answer They are called linemarkers and you can use -P to… May 13, 2026 at 7:22 pm
  • Editorial Team
    Editorial Team added an answer It turns out that there were two issues going on.… May 13, 2026 at 7:22 pm

Related Questions

I'm working on a side project that would be a simple web application to
I maintain a cross platform application, based on PyQt that runs on linux mac
I'm asking myself how to apply MVVM in the following scenario correctly: Let's assume
I have a SQL script that inserts data (via INSERT statements currently numbering in
I have a Perl script where I maintain a very simple cache using a

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.