The simplest way to put the MRU list in a submenu


Full Text Search: The Key to Better Natural Language Queries for NoSQL in Node.js

Environment: Tested on NT 4.0 SP3, VC6.0

Putting the MRU list in a submenu might appear just a matter to move the menu item ID_FILE_MRU_FILE1 from the 'File' menu to a submenu. Unfortunately a bug (of the CRecentFileList class I read but I believe that it's elsewhere in the framework) makes the things more complicated. As you can verify, even if it's unbelievable, the MRU list continues to appear in the main "File" menu! After some hours of deep desperation, I found a simple workaround. Once again, the solution came from an accurate analysis of the MFC code.

Using the ClassWizard, add the UPDATE_COMMAND_UI handler for the ID_FILE_MRU_FILE1 command to your application class and call it OnUpdateMruFile1. Then, just insert the following two lines of code:

void CMyApp::OnUpdateFileMruFile1(CCmdUI* pCmdUI) { 
	if (pCmdUI->m_nIndex == 0)

The OnUpdateRecentFileMenu() is the CWinApp own handler for ID_FILE_MRU_FILE1.

Note that the check:

	pCmdUI->m_nIndex == 0 

Relies on the fact that the ID_FILE_MRU_FILE1 item is the first item of its submenu. Therefore, the MRU list will never be updated if you insert some item before it.

I believe this be the simplest way to put the MRU list in a submenu.


  • Error with a handler function

    Posted by Legacy on 08/31/1999 12:00am

    Originally posted by: Shehzad Khan

    I've changed the "Recent Files" menu item to be a pop-up and added a handler:

    void CScoringModelDlg::OnUpdateFileMruFile1(CCmdUI* pCmdUI)
    // TODO: Add your command update UI handler code here

    if (pCmdUI->m_nIndex == 0)

    But I get this error:

    'OnUpdateRecentFileMenu' undeclared identifier.

    You've mentioned that this function is a CWinApp handler. I could not find it anywhere.

Leave a Comment
  • Your email address will not be published. All fields are required.

Top White Papers and Webcasts

  • Cloud has the potential to offer many benefits that can enable great success within your business. However, there are still many myths floating around about backing up to the cloud. In this eBook, you'll discover the truth about five of the most common cloud myths, including myths about security, maintaining regulatory compliance and more. Get to the truth, so you can backup to the cloud with confidence.

  • Why use NoSQL? Innovative companies like AT&T, GE, and PayPal have successfully transitioned from relational to NoSQL for their critical web, mobile, and IoT applications. By understanding where to introduce NoSQL, how to model and access the data, and how to manage and monitor a distributed database, you can do the same. This white paper explains the need for non-relational databases, describes advantages of NoSQL, and clarifies the important difference between SQL and NoSQL databases. We walk you …

Most Popular Programming Stories

More for Developers

RSS Feeds

Thanks for your registration, follow us on our social networks to keep up-to-date