How to remove menu by ID?

Posted on 1998-04-24
Last Modified: 2013-11-19
I want to remove a menu IDR_MENU1 from the IDR_MAINFRAME.
Why my pmenu->RemoveMenu(IDR_MENU1, MF_BYCOMMAND) doesn't
work ?

IDR_MENU1 is a menu added to the IDR_MAINFRAME
via LoadMenu() command dynamically?

BOOL CMainFrame::MenuUnLoad(UINT MenuId)
      CMenu* pmenu = GetMenu();
//      pmenu->RemoveMenu(1, MF_BYPOSITION);  // This works
      pmenu->RemoveMenu(IDR_MENU1, MF_BYCOMMAND); // This doesn't
      return TRUE;
Question by:nancytan
  • 5
  • 2

Author Comment

ID: 1302112
Edited text of question

Author Comment

ID: 1302113
Edited text of question

Author Comment

ID: 1302114
Edited text of question
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline


Author Comment

ID: 1302115
Edited text of question
LVL 10

Accepted Solution

RONSLOW earned 20 total points
ID: 1302116
You main menu is a menu.  It has submenus.  These cannot be removed by command, because they don't have commands - they are just submenus.  You can only remove a menu item by command (eg ID_FILE_NEW)


Author Comment

ID: 1302117
So, there is no way to remove submenu other then by using
 pmenu->RemoveMenu(1, MF_BYPOSITION)?
LVL 10

Expert Comment

ID: 1302118
That is so (to the best of my knowledge)

Of course, you should be able to loop thru your menu and find a submenu that contains an item with a known id, then remove that submenu.

Or you can rely on knowing the order (eg help menu always last, file menu always first etc).


Featured Post

What Is Threat Intelligence?

Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

Join & Write a Comment

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
Introduction: Dynamic window placements and drawing on a form, simple usage of windows registry as a storage place for information. Continuing from the first article about sudoku.  There we have designed the application and put a lot of user int…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…

707 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now