Disabling main menu items 
Author Message
 Disabling main menu items

I have an IDR_MAINFRAME main menu in an SDI application. Is there any
way to disable a whole top level selection (and subordinates) based on a
condition?

Like, disable the Edit menu and all items under it if a document isn't
loaded?

I have done that with sub items using CView::OnUpdate() but there is no
ID number for the top level menu item, and I can't get Class Wiz to
create an OnUpdate method for it.

Or do I have to do it separately for each sub item underneath?

Thanks.



Mon, 04 Oct 2004 01:21:56 GMT  
 Disabling main menu items

Quote:

>but there is no
>ID number for the top level menu item, and I can't get Class Wiz to
>create an OnUpdate method for it.

You use EnableMenuItem and reference menu bar items by _position_.

e.g.

CMenu * pMenu = GetMenu ();
if (pMenu)
  pMenu->EnableMenuItem (0, MF_GRAYED|MF_BYPOSITION);
DrawMenubar();

Will gray out the leftmost item on your window's menubar.

--
Bob Moore [WinSDK MVP]
http://www.mooremvp.freeserve.co.uk/
(this is a non-commercial site and does not accept advertising)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Do not reply via email unless specifically requested to do so.
Unsolicited email is NOT welcome and will go unanswered.
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



Mon, 04 Oct 2004 03:48:15 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Disabling main menu items in MFC based apps

2. How to disable/enable Popup menu item of the main menu

3. Disabling menu option on main menu bar

4. Enabling Menu Item in Main Menu?

5. Trying to disable Menu Item and ToolbarCtrl item..

6. Disable menu item in popup menu

7. Enabling/Disabling Menu items for a menu on a dialog application

8. repaint main menu items after MF_GRAYED

9. disable the main menu

10. deleting a main menu item

11. Main Menu Looks Disabled??

12. Main Menu looks disabled

 

 
Powered by phpBB® Forum Software