GetMenuState function (winuser.h)
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 GetMenuState(
[in] HMENU hMenu,
[in] UINT uId,
[in] UINT uFlags
);
Parameters
[in] hMenu
Type: HMENU
A handle to the menu that contains the menu item whose flags are to be retrieved.
[in] uId
Type: UINT
The menu item for which the menu flags are to be retrieved, as determined by the uFlags parameter.
[in] uFlags
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
Requirement | Value |
---|---|
Minimum supported client | Windows 2000 Professional [desktop apps only] |
Minimum supported server | Windows 2000 Server [desktop apps only] |
Target Platform | Windows |
Header | winuser.h (include Windows.h) |
Library | User32.lib |
DLL | User32.dll |
API set | ext-ms-win-ntuser-menu-l1-1-2 (introduced in Windows 10, version 10.0.10240) |
See also
Conceptual
Reference