Click here to Skip to main content
15,507,012 members
Articles / Programming Languages / C++
Posted 20 Sep 2020

Tagged as


2 bookmarked

Disable MFC SDI/MDI Submenu

Rate me:
Please Sign up or sign in to vote.
3.67/5 (6 votes)
20 Sep 2020CPOL
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)

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



  • 21st September, 2020: Initial version


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Written By
Software Developer (Senior)
Singapore Singapore
Shao Voon is from Singapore. His interest lies primarily in computer graphics, software optimization, concurrency, security, and Agile methodologies. His hobby is writing a free C++/DirectX photo slideshow application which can be viewed here.

Comments and Discussions

GeneralMy vote of 1 Pin
Victor Nijegorodov31-Oct-20 1:09
Victor Nijegorodov31-Oct-20 1:09 
What the hell to public what was known from the beginning of MFC history?
GeneralRe: My vote of 1 Pin
Shao Voon Wong31-Oct-20 2:04
mvaShao Voon Wong31-Oct-20 2:04 
Questionhow to make submenu item invisible? Pin
Southmountain6-Oct-20 14:29
Southmountain6-Oct-20 14:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.