WM_COMMAND
TheWM_COMMANDmessage 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.
A window receives this message through itsWindowProcfunction.
LRESULT CALLBACK WindowProc( HWNDhwnd,// handle to window UINTuMsg,// WM_COMMAND WPARAMwParam,// notification code and identifier LPARAMlParam// handle to control (HWND));
ParameterswParamThe 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 ValuesIf an application processes this message, it should return zero.
RemarksAccelerator keystrokes that select items from the window menu are translated intoWM_SYSCOMMANDmessages.
If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, noWM_COMMANDmessage 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, aWM_COMMANDmessage is sent, even if the window is minimized.
If an application enables a menu separator, the system sends aWM_COMMANDmessage with the low-word of thewParamparameter set to zero when the user selects the separator.
Windows 98, Windows 2000:If a menu is defined with aMENUINFO.dwStylevalue of MNS_NOTIFYBYPOS,WM_MENUCOMMANDis sent instead ofWM_COMMAND.
RequirementsWindows NT/2000:Requires Windows NT 3.1 or later.
Windows 95/98:Requires Windows 95 or later.
Header:Declared in Winuser.h; include Windows.h.
See AlsoMenus Overview, Menu Messages,HIWORD,LOWORD,MENUINFO,WM_MENUCOMMAND,WM_SYSCOMMAND
WM_COMMAND(上文翻译)
TheWM_COMMANDmessage 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.
当用户从菜单选中一个命令项目、当一个控件发送通知消息给去父窗口或者按下一个快捷键将发送WM_COMMAND消息
A window receives this message through itsWindowProcfunction.
窗口通过WindowProc函数收到此消息。
LRESULT CALLBACK WindowProc( HWNDhwnd,// handle to window UINTuMsg,// WM_COMMAND WPARAMwParam,// notification code and identifier LPARAMlParam// handle to control (HWND));
LRESULT CALLBACK WindowProc( HWNDhwnd,// 窗口句柄
UINTuMsg,// WM_COMMAND
WPARAMwParam,// notification code and identifier 消息
LPARAMlParam// handle to control (HWND) 控件id
);
ParameterswParamThe high-order word specifies the notification code if the message is from a control.参数wParam高阶词指定通知代码如果邮件是从控制。
If the message is from an accelerator, this value is 1.如果邮件是从一个加速器,这个值是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.
lParam句柄控制传送邮件如果邮件是从控制。
Otherwise, this parameter is NULL.否则,这个参数是无效的。
Return ValuesIf an application processes this message, it should return zero.
返回ValuesIf应用程序这个讯息,它应返回零。
RemarksAccelerator keystrokes that select items from the window menu are translated intoWM_SYSCOMMANDmessages. RemarksAccelerator击键的选择项目从窗口菜单化为WM_SYSCOMMAND消息。
If an accelerator keystroke occurs that corresponds to a menu item when the window that owns the menu is minimized, noWM_COMMANDmessage is sent.如果出现一个加速器按键对应的菜单项时的窗口,拥有菜单最小,没有WM_COMMAND发送邮件。 However, if an accelerator keystroke occurs that does not match any of the items in the window's menu or in the window menu, aWM_COMMANDmessage is sent, even if the window is minimized.但是,如果出现一个加速器按键不匹配的任何物品在窗口的菜单或窗口菜单,一个WM_COMMAND消息发送,即使是最小化的窗口。
If an application enables a menu separator, the system sends aWM_COMMANDmessage with the low-word of thewParamparameter set to zero when the user selects the separator.如果应用程序使菜单分离,系统发出了一个WM_COMMAND消息的低字的wParam参数设置为0时,用户选择的分隔符。
Windows 98, Windows 2000:If a menu is defined with aMENUINFO.dwStylevalue of MNS_NOTIFYBYPOS,WM_MENUCOMMANDis sent instead ofWM_COMMAND.Windows 98中, Windows 2000中:如果一个菜单的定义与MENUINFO.dwStyle价值MNS_NOTIFYBYPOS ,WM_MENUCOMMAND发送不是WM_COMMAND。
RequirementsWindows NT/2000:Requires Windows NT 3.1 or later.要求视窗NT/2000:需要Windows NT 3.1或更高版本。
Windows 95/98:Requires Windows 95 or later.视窗95/98 :需要Windows 95或更新版本。
Header:Declared in Winuser.h; include Windows.h.标题:中宣布的Winuser.h ;包括Windows.h 。
See AlsoMenus Overview, Menu Messages,HIWORD,LOWORD,MENUINFO,WM_MENUCOMMAND,WM_SYSCOMMAND查看AlsoMenus概况,菜单消息,HIWORD,LOWORD,MENUINFO,WM_MENUCOMMAND,WM_SYSCOMMAND