CMenu::GetMenuState

Syntax

UINT GetMenuState( UINT nID, UINT nFlags ) const;

Parameters

nID

Specifies the menu item ID, as determined by nFlags.

nFlags

Specifies the nature of nID. It can be one of the following values:

Value Interpretation of nFlags

MF_BYCOMMAND Specifies that the parameter gives the command ID of the existing menu item. This is the default if neither MF_BYCOMMAND nor MF_BYPOSITION is set.
MF_BYPOSITION Specifies that the parameter gives the position of the existing menu item (the first item is at position 0).

Remarks

Returns the status of the specified menu item or the number of items in a pop-up menu.

Return Value

The value -1 if the specified item does not exist. If nId identifies a pop-up menu, the high-order byte contains the number of items in the pop-up menu and the low-order byte contains the menu flags associated with the pop-up menu. Otherwise the return value is a mask (Boolean OR) of the values from the following list (this mask describes the status of the menu item that nId identifies):

Value Meaning

MF_CHECKED Acts as a toggle in conjunction with MF_UNCHECKED to place the default check mark next to the item. When the application supplies check-mark bitmaps (see SetMenuItemBitmaps), the “check mark on” bitmap is displayed.
MF_DISABLED Disables the menu item so that it cannot be selected, but does not dim it.
MF_ENABLED Enables the menu item so that it can be selected, and restores it from its dimmed state.
MF_GRAYED Disables the menu item so that it cannot be selected, and dims it.
MF_MENUBARBREAK Places item on a new line in static menus or in a new column in pop-up menus. The new pop-up menu column will be separated from the old column by a vertical dividing line.
MF_MENUBREAK Places item on a new line in static menus or in a new column in pop-up menus. No dividing line is placed between the columns.
MF_SEPARATOR Draws a horizontal dividing line. Can only be used in a pop-up menu. This line cannot be dimmed, disabled, or highlighted. Other parameters are ignored.
MF_UNCHECKED Acts as a toggle in conjunction with MF_CHECKED to remove a check mark next to the item. When the application supplies check-mark bitmaps (see SetMenuItemBitmaps), the “check mark off” bitmap is displayed.

See Also

::GetMenuState, CMenu::CheckMenuItem, CMenu::EnableMenuItem