Solved

How to remove menu by ID?

Posted on 1998-04-24
7
303 Views
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
      DrawMenuBar();
      return TRUE;
}
0
Comment
Question by:nancytan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 2
7 Comments
 

Author Comment

by:nancytan
ID: 1302112
Edited text of question
0
 

Author Comment

by:nancytan
ID: 1302113
Edited text of question
0
 

Author Comment

by:nancytan
ID: 1302114
Edited text of question
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:nancytan
ID: 1302115
Edited text of question
0
 
LVL 10

Accepted Solution

by:
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)

0
 

Author Comment

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

Expert Comment

by:RONSLOW
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).

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Installing Microsoft R server on REDHAT or SUSE Linux 4 152
Pressing cancel button with C# UI Automation 3 92
zeroMAx challenge 20 126
Authenticate using sesu from script 7 112
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
Introduction: Database storage, where is the exe actually on the disc? Playing a game selected randomly (how to generate random numbers).  Error trapping with try..catch to help the code run even if something goes wrong. Continuing from the seve…
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.
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 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