locked
LoadStdProFileSettings and MRU list RRS feed

  • Question

  • I have a question regarding LoadStdProfileSettings() and the MFC framework automatically updating the menu item FILE | Recent Files-> MRU List.    In the past, for a MFC projects with document views,  the system automatically put the MRU list in the menu.

    But for this new MFC project, I am porting an original code which was written in the old Borland v4.5 OWL framework.   After I was able to basically convert the OWL based dialogs in the *.RC file to MFC style and got the basic GUI layout, I then began to fill in the VC10 C/C++ ported guts, the handlers, tediously one by one.   The original code did not use a doc/view, of course, and it used its own set of menu file open/save/save as menu ID with OWL based and equivalent ON_COMMON and ON_UPDATE_COMMAND_UI_RANGE handlers off the CFrameWnd.  It also internally kept the list of files since it used a archive stream storage for settings and it dynamically created the MRU menu list.

    My question is whether this is something I had to repeat or will MFC do it for you if prepared correctly, like it does for a DOC/VIEW framework?

    The InitInstance() handler is calling LoadStdProfileSettings() and I also changed the MENU Open/New ID to the standard ID_FILE_OPEN, ID_FILE_NEW for the main App class to capture these events and have then call AddToRecentFileList() to populate the storage list.  Upon exit, I can see the storage in the registry and LoadStdProfileSettings() does reload it, but I don't it being added to the File Menu.

    Do I have to do this manually?

    Thanks

     

     


    Hector Santos, http://www.santronics.com
    Via Wildcat! Live Exchange NNTP Gateway http://opensite.winserver.com
    Thursday, January 12, 2012 3:59 PM

Answers

  • Problem solved, adding a menu item UI update handler for the range of IDs with the following solved it:

    void CMyWinApp::OnUpdateFileMRUList(CCmdUI *pCmdUI)
    {
        if (pCmdUI->m_pSubMenu!=NULL) {
            return;
        }
        // Update list here
        if (m_pRecentFileList) {
            m_pRecentFileList->UpdateMenu(pCmdUI);  // <--- SOLUTION
            return;
        }
    }
    
    

     


    Hector Santos, http://www.santronics.com
    Via Wildcat! Live Exchange NNTP Gateway http://opensite.winserver.com
    Thursday, January 12, 2012 5:24 PM

All replies

  • Problem solved, adding a menu item UI update handler for the range of IDs with the following solved it:

    void CMyWinApp::OnUpdateFileMRUList(CCmdUI *pCmdUI)
    {
        if (pCmdUI->m_pSubMenu!=NULL) {
            return;
        }
        // Update list here
        if (m_pRecentFileList) {
            m_pRecentFileList->UpdateMenu(pCmdUI);  // <--- SOLUTION
            return;
        }
    }
    
    

     


    Hector Santos, http://www.santronics.com
    Via Wildcat! Live Exchange NNTP Gateway http://opensite.winserver.com
    Thursday, January 12, 2012 5:24 PM
  • Thanks for sharing the solution.

     

    Best regards,

    Jesse


    Jesse Jiang [MSFT]
    MSDN Community Support | Feedback to us
    Monday, January 16, 2012 8:31 AM
    Moderator