Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

Disable MFC SDI/MDI Submenu

0.00/5 (No votes)
20 Sep 2020 1  
How to disable MFC SDI/MDI Submenu
In this tip, you will see the steps to disable MFC SDI/MDI submenu.

The example code is hosted at Github.

Follow the steps to disable your MFC submenu in the SDI/MDI application. First, create a submenu by typing in the menu editor in Visual Studio.

Create Menu

Right-click on the new submenu to bring up the context menu and select the "Add Event Handler".

Add Event Handler

In the event handler dialog, in the class dropdown, select CMainFrame.. And in the Message Type dropdown, select UPDATE_COMMAND_UI and click OK button.

Event Handler Dialog

This function handler is added by the event handler dialog.

void CMainFrame::OnUpdateFileMymenu(CCmdUI* pCmdUI)
{
	// TODO: Add your command update UI handler code here
}

Delete the comment and add this line to disable your submenu. This handler is called whenever your menu is about to be displayed.

void CMainFrame::OnUpdateFileMymenu(CCmdUI* pCmdUI)
{
	pCmdUI->Enable(FALSE);
}

Build and run the application to see if the menu is disabled.

MenuDisabled.png

History

  • 21st September, 2020: Initial version

License

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