65.9K
CodeProject is changing. Read more.
Home

Disable MFC SDI/MDI Submenu

starIconstarIconstarIcon
emptyStarIcon
starIcon
emptyStarIcon

3.67/5 (6 votes)

Sep 21, 2020

CPOL
viewsIcon

6241

downloadIcon

91

How 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