Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Sent to a menu's owner window when the user selects a menu item.
#define WM_MENUSELECT 0x011F
Parameters
-
wParam
-
The low-order word specifies the menu item or submenu index. If the selected item is a command item, this parameter contains the identifier of the menu item. If the selected item opens a drop-down menu or submenu, this parameter contains the index of the drop-down menu or submenu in the main menu, and the lParam parameter contains the handle to the main menu; use the GetSubMenu function to get the menu handle to the drop-down menu or submenu.
The high-order word specifies one or more menu flags. This parameter can be one or more of the following values.
Value Meaning - MF_BITMAP
- 0x00000004L
Item displays a bitmap. - MF_CHECKED
- 0x00000008L
Item is checked. - MF_DISABLED
- 0x00000002L
Item is disabled. - MF_GRAYED
- 0x00000001L
Item is grayed. - MF_HILITE
- 0x00000080L
Item is highlighted. - MF_MOUSESELECT
- 0x00008000L
Item is selected with the mouse. - MF_OWNERDRAW
- 0x00000100L
Item is an owner-drawn item. - MF_POPUP
- 0x00000010L
Item opens a drop-down menu or submenu. - MF_SYSMENU
- 0x00002000L
Item is contained in the window menu. The lParam parameter contains a handle to the menu associated with the message. -
lParam
-
A handle to the main menu.
Return value
If an application processes this message, it should return zero.
Remarks
This message is sent to a menu's owner window when the user selects a menu item in an open menu, typically by mouse-over or keyboard navigation. If the menu is closed, this message is not sent when the user moves the mouse over a top-level menu item. This message is sent only after the menu is opened by the user clicking a top-level menu item or pressing the ALT key.
Important
When a user clicks a menu item or presses Enter to invoke a selected menu item, a WM_COMMAND or WM_MENUCOMMAND message is sent to the window, depending on the value of the dwStyle member of the MENUINFO structure for the menu. Use those messages to perform an action when the selected command is invoked.
If the high-order word of wParam contains 0xFFFF and the lParam parameter contains NULL, the system has closed the menu.
Do not use the value -1 for the high-order word of wParam, because this value is specified as (UINT) HIWORD(wParam). Even though 0xFFFF might be interpreted as -1 in signed contexts, if the value is 0xFFFF, it would be interpreted as 0x0000FFFF, not -1, because of the cast to a UINT.
For example, this code checks for 0xFFFF, not -1:
case WM_MENUSELECT:
{
UINT menuItem = LOWORD(wParam);
UINT flags = HIWORD(wParam);
HMENU hMenu = (HMENU)lParam;
// Check for 0xFFFF, not -1.
if (flags == 0xFFFF && hMenu == NULL) {
// No menu item selected (menu closed).
// ...
}
break;
}
Requirements
| Requirement | Value |
|---|---|
| Minimum supported client |
Windows 2000 Professional [desktop apps only] |
| Minimum supported server |
Windows 2000 Server [desktop apps only] |
| Header |
|
See also
-
Reference
-
Conceptual