WM_COMMAND Notification
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.
Syntax
WM_COMMAND WPARAM wParam LPARAM lParam;
Parameters
wParamThe high-order word specifies the notification code if the message is from a control. If the message is from an accelerator, this value is 1. If the message is from a menu, this value is zero.The low-order word specifies the identifier of the menu item, control, or accelerator.
lParamHandle to the control sending the message if the message is from a control. Otherwise, this parameter is NULL.
Return Value
If an application processes this message, it should return zero.
Remarks
Accelerator keystrokes that select items from the window menu are translated into WM_SYSCOMMAND messages.
If an accelerator keystroke occurs that corresponds to a menu item 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 in the window's menu or in the window menu, a WM_COMMAND message is sent, even if the window is minimized.
If an application enables a menu separator, the system sends a WM_COMMAND message with the low-word of the wParam parameter set to zero when the user selects the separator.
Windows 98/Me, Windows 2000/XP: If a menu is defined with a MENUINFO.dwStyle value of MNS_NOTIFYBYPOS, WM_MENUCOMMAND is sent instead of WM_COMMAND.
CBN_SELCHANGE Notification
The CBN_SELCHANGE notification message is sent when the user changes the current selection in the list box of a combo box. The user can change the selection by clicking in the list box or by using the arrow keys. The parent window of the combo box receives this notification in the form of a WM_COMMAND message with CBN_SELCHANGE in the high-order word of the wParam parameter.
Syntax
CBN_SELCHANGE WPARAM wParam LPARAM lParam;
Parameters
wParamThe low-order word specifies the control identifier of the combo box.The high-order word specifies the notification message.
lParamHandle to the combo box.
Return Value
No return value.
Remarks
To get the index of the current selection, send the CB_GETCURSEL message to the control.
The CBN_SELCHANGE notification message is not sent when the current selection is set using the CB_SETCURSEL message.
MAKEWPARAM Macro
The MAKEWPARAM macro creates a value for use as a wParam parameter in a message. The macro concatenates the specified values.
Syntax
WPARAM MAKEWPARAM(
WORD wLow, WORD wHigh);
Parameters
wLowSpecifies the low-order word of the new value.wHighSpecifies the high-order word of the new value.
Return Value
The return value is a WPARAM value.