Click to See Complete Forum and Search --> : How to programmatically hide a main menu item


Will Rothwell
May 10th, 1999, 12:55 AM
Hi gurus,

Can someone tell me how to 'Hide' and 'Show' a main menu item, in respsonse to a user selection of some other option. The main item was created with the Resource Editor. I want to make one of the main menu items (and all its submenu items) disappears for some operation mode.

I have posted this Q before but no joy. Please advise.


Will

Jason Teagle
May 10th, 1999, 03:10 AM
One method is to define two menus - the main one which has everything, and the other which mirrors the first but removes the required menu item from the top level; you can then use the SetMenu method to use the new menu. However, this interferes with the MFC framework use of menus (i.e., when a document is open there is a view-type menu in place of the main menu), and of course, if you wanted to hide different top-level menus for different situations you would have to define multiple menus.

A second method is to have all the menu items which you want to be able to dynamically show or hide as popups from one permanent top-level menu - for example, the permanent menu could be called Functions and the popups within that menu could be Sin, Cos and Tan and could be shown or hidden at will. This approach is slightly more complicated, but does not interfere with the MFC framework.

If these approaches are no good, e-mail me at jteagle@solartron.com and I'll see if I can magic up something else.