Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Enabling menu's and sub menu's 1

Status
Not open for further replies.

shetlandbob

Programmer
Mar 9, 2004
528
GB
Hia I have a menu of the following format:


Menu
Item1
item2 SubItem2.1
SubItem2.2


If you follow? subitems2.1and 2.2 are activated by item2. ok?

Anyway I know how to disable and grey out an item using the item ID e.g.

subMenu->EnableMenuItem(ID_SUBITEM21, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED );

How can I disable both (or all) my sub menu items by a single command to diable (and grey out) my menu "Item2" (I cant find out how to determine the ID of this menu item)?
Rather than disabling every item in the sub menu?
 
shetlandbob said:
Anyway I know how to disable and grey out an item using the item ID e.g.

subMenu->EnableMenuItem(ID_SUBITEM21, MF_BYCOMMAND | MF_DISABLED | MF_GRAYED );

The MF_BYCOMMAND flag means that the first parameter is the item ID.

However, if you use the MF_BYPOSITION flag, you can pass the ordinal position of the item in the first parameter. Ordinal positions start numbering at zero. So for disabling the submenu you might do

[tt]menu->EnableMenuItem(1,MF_BYCOMMAND|MF_GRAYED);[/tt]

By the way, you don't need to specify MF_DISABLED. MF_GRAYED implies disablement.

[sub]I REALLY hope that helps.[/sub]
Will
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top