WM_COMMAND
idItem = wParam; /* control or menu item identifier */
hwndCtl = (HWND) LOWORD(lParam); /* handle of control */
wNotifyCode = HIWORD(lParam); /* notification message */
The WM_COMMAND message is sent to a window when the user selects an item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.
idItem
Value of wParam. Specifies the identifier of the menu item or control.
hwndCtl
Value of the low-order word of lParam. Identifies the control sending the message if the message is from a control. Otherwise, this parameter is zero.
wNotifyCode
Value of the high-order word of lParam. Specifies the notification message if the message is from a control. If the message is from an accelerator, this parameter is 1. If the message is from a menu, this parameter is 0.
An application should return zero if it processes this message.
Accelerator keystrokes that are defined to select items from the System menu (sometimes referred to as the Control menu) are translated into WM_SYSCOMMAND messages.
If an accelerator keystroke that corresponds to a menu item occurs when the window that owns the menu is minimized, no WM_COMMAND message is sent. However, if an accelerator keystroke occurs that does not match any of the items on the window's menu or on the System menu, a WM_COMMAND message is sent even if the window is minimized.
This example creates an Options dialog box in response to a WM_COMMAND message sent as a result of a menu selection:
FARPROC lpProc;
case WM_COMMAND:
switch (wParam) {
case IDM_OPTIONS:
lpProc = MakeProcInstance(OptionsProc, hInstance);
DialogBox(hInstance, "OptionsBox", hwnd, lpProc);
FreeProcInstance(lpProc);
break;
.
. /* Process other menu commands. */
.
}
break;