WM_MENUCHAR

2.x

WM_MENUCHAR
chUser = wParam;                    /* ASCII character    */
fMenu = LOWORD(lParam);             /* menu flag          */
hmenu = (HMENU) HIWORD(lParam);     /* handle of the menu */

The WM_MENUCHAR message is sent when the user presses the key corresponding to a menu mnemonic character that doesn't match any of the predefined mnemonics in the current menu. It is sent to the window that owns the menu.

Parameters

chUser

Value of wParam. Specifies the ASCII character that corresponds to the key the user pressed.

fMenu

Value of the low-order word of lParam. Specifies the type of the selected menu. This parameter can be one of the following values:

Value Meaning

MF_POPUP The menu is a pop-up menu.
MF_SYSMENU The menu is a System menu (sometimes referred to as a Control menu).

hmenu

Value of the high-order word of lParam. Identifies the selected menu.

Return Value

The return value is one of the following command code values in the high-order word:

Value Description

0 Informs Windows that it should discard the character corresponding to the key the user pressed, and creates a short beep on the system speaker.
1 Informs Windows that it should close the current menu.
2 Informs Windows that the low-order word of the return value contains the item number for a specific item. This item is selected by Windows.

The low-order word is ignored if the high-order word contains 0 or 1. An application should process this message when an accelerator key has been used to select a bitmap placed in a menu.

Comments

The WM_MENUCHAR message is generated when the user presses ALT and any key, even if the key does not correspond to a mnemonic character. In this case, the hmenu parameter contains the window handle of the menu.