MAKEWPARAM

来源:互联网 发布:长城c50轮毂数据 编辑:程序博客网 时间:2024/04/30 16:18

以下摘自MSDN:

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. WM_COMMAND消息在三种情况下被发送: 1.用户选择一个菜单项 2.控件向自己的父窗口发送通知消息 3.加速键被按下三种情况对应的wParam和lParam参数用法如下(MSDN):

Message Source wParam (high word) wParam (low word) lParam Menu 0 Menu identifier (IDM_*) 0 Accelerator 1 Accelerator identifier (IDM_*) 0 Control Control-defined notification code Control identifier Handle to the control window

注意一下wParam参数,被分为高字和低字,那当我们需要自己send WM_COMMAND 消息时,怎样来制作wParam参数呢?可以使用MAKEWPARAM宏,下面是我项目中的一句代码: SendMessage(WM_COMMAND,MAKEWPARAM(IDC_BUTTON_AMEND,BN_CLICKED),(LPARAM)listview->m_btnAmend.m_hWnd);     //发送一个按钮单击消息。

类似的宏还有: MAKELONG  制作一个长整型的参数 MAKELPARAM  制作一个lParam参数 MAKELRESULT 制作一个从窗口程序或者回调函数返回的32位值