When a user chooses a menu item, the client window procedure receives a WM_COMMAND message with SHORT1FROMMP(mp1) equal to the menu identifier of the chosen item. Your application must use the menu identifier to guide its response to the choice. Typically, the code in the client window procedure resembles the following code fragment:
case WM_COMMAND: DoMenuCommand(hwnd, SHORT1FROMMP(mp1)); return 0;The function that translates the menu identifier into an action typically resembles the following code fragment:
VOID DoMenuCommand( HWND hwnd, USHORT usItemID) { /* Test the menu item. */ switch (usItemID) { case IDM_FI_NEW: DoNew(hwnd); break; . . /* etc. */ . } }
The menu window sends a WM_MENUSELECT message every time the menu selection changes. SHORT1FROMMP(mp1) contains the identifier of the item that is changing state, and SHORT2FROMMP(mp2) is a 16-bit Boolean value that describes whether or not the item is chosen; the mp2 parameter contains the handle of the menu.
If the Boolean value is FALSE, the item is selected but not chosen; for example, the user may have moved the cursor or mouse pointer over the item while the button was down. An application can use this message to display Help information at the bottom of the application window. The return value is ignored.
If the Boolean value is TRUE, the item is chosen-that is, the user pressed Enter or released the mouse button while an item was selected. If the application returns FALSE, the menu does not generate a WM_COMMAND, WM_SYSCOMMAND, or WM_HELP message, and the menu is not dismissed.