GetMenuState function
Retrieves the menu flags associated with the specified menu item. If the menu item opens a submenu, this function also returns the number of items in the submenu.
Syntax
UINT WINAPI GetMenuState( _In_ HMENU hMenu, _In_ UINT uId, _In_ UINT uFlags );
Parameters
- hMenu [in]
-
Type: HMENU
A handle to the menu that contains the menu item whose flags are to be retrieved.
- uId [in]
-
Type: UINT
The menu item for which the menu flags are to be retrieved, as determined by the uFlags parameter.
- uFlags [in]
-
Type: UINT
Indicates how the uId parameter is interpreted. This parameter can be one of the following values.
Return value
Type: UINT
If the specified item does not exist, the return value is -1.
If the menu item opens a submenu, the low-order byte of the return value contains the menu flags associated with the item, and the high-order byte contains the number of items in the submenu opened by the item.
Otherwise, the return value is a mask (Bitwise OR) of the menu flags. Following are the menu flags associated with the menu item.
| Return code/value | Description |
|---|---|
|
A check mark is placed next to the item (for drop-down menus, submenus, and shortcut menus only). |
|
The item is disabled. |
|
The item is disabled and grayed. |
|
The item is highlighted. |
|
This is the same as the MF_MENUBREAK flag, except for drop-down menus, submenus, and shortcut menus, where the new column is separated from the old column by a vertical line. |
|
The item is placed on a new line (for menu bars) or in a new column (for drop-down menus, submenus, and shortcut menus) without separating columns. |
|
The item is owner-drawn. |
|
Menu item is a submenu. |
|
There is a horizontal dividing line (for drop-down menus, submenus, and shortcut menus only). |
Remarks
It is possible to test an item for a flag value of MF_ENABLED, MF_STRING, MF_UNCHECKED, or MF_UNHILITE. However, since these values equate to zero you must use an expression to test for them.
| Flag | Expression to test for the flag |
|---|---|
| MF_ENABLED | ! (Flag&(MF_DISABLED | MF_GRAYED)) |
| MF_STRING | ! (Flag&(MF_BITMAP | MF_OWNERDRAW)) |
| MF_UNCHECKED | ! (Flag&MF_CHECKED) |
| MF_UNHILITE | ! (Flag&HILITE) |
Examples
For an example, see Simulating Check Boxes in a Menu.
Requirements
|
Minimum supported client |
Windows 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server |
Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
- Reference
- GetMenu
- GetMenuItemCount
- GetMenuItemID
- GetMenuItemInfo
- Conceptual
- Menus