WM_COMMAND

WM_COMMAND

wNotifyCode = HIWORD(wParam); /* notification code */

wID = LOWORD(wParam); /* item, control, or accelerator ID */

hwndCtl = (HWND) lParam; /* handle of control */

The WM_COMMAND message is sent when the user selects a command item from a menu, when a control sends a notification message to its parent window, or when an accelerator keystroke is translated.

Parameters

wNotifyCode

Value of the high-order word of wParam. Specifies the notification code 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.

wID

Value of the low-order word of wParam. Specifies the identifier of the menu item, control, or accelerator.

hwndCtl

Value of lParam. Identifies the control sending the message if the message is from a control. Otherwise, this parameter is NULL.

Return Value

An application should return zero if it processes this message.

Comments

Accelerator keystrokes that are defined to select items from the System 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 that does not match any of the items on the window's menu or on the System menu occurs, a WM_COMMAND message is sent, even if the window is minimized.

See Also

WM_SYSCOMMAND