MFC中怎样区分WM_COMMAND是谁产生?

newHung 2006-07-25 11:07:43
菜单项、工具栏的按钮的点击,都产生WM_COMMAND消息。怎么样区别具体是由谁(哪一个ID)产生的消息。
sdk中可以通过消息的附加参数LOWORD (wParam)来识别,MFC中也是这样吗?可是wParam在哪里可以获得呢?
...全文
168 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
思危 2006-08-06
  • 打赏
  • 举报
回复
ON_COMMAND(id, memberFxn ), 中的id就是
m_dbsky 2006-08-06
  • 打赏
  • 举报
回复
去看一下MFC内部机制方面的书
cybermat 2006-08-06
  • 打赏
  • 举报
回复
ON_COMMAND(id, memberFxn )宏不是要传弟一个参数的吗?你要是知道ID怎么添加这个宏呢
cleverwyq 2006-07-25
  • 打赏
  • 举报
回复
CWinApp::PreTranslateMessage See Also
CWinApp Overview | Class Members | Hierarchy Chart | DispatchMessage | TranslateMessage
Override this function to filter window messages before they are dispatched to the Windows functions TranslateMessage and DispatchMessage The default implementation performs accelerator-key translation, so you must call the CWinApp::PreTranslateMessage member function in your overridden version.

virtual BOOL PreTranslateMessage(
MSG* pMsg
);
Parameters
pMsg
A pointer to a MSG structure that contains the message to process.


/////////
MSG StructureSee Also
Structures, Styles, Callbacks, and Message Maps
The MSG structure contains message information from a thread's message queue.

typedef struct tagMSG { // msg
HWND hwnd;
UINT message;
WPARAM wParam;
LPARAM lParam;
DWORD time;
POINT pt;
} MSG;
Parameters
hwnd
Identifies the window whose window procedure receives the message.
message
Specifies the message number.
wParam
Specifies additional information about the message. The exact meaning depends on the value of the message member.
lParam
Specifies additional information about the message. The exact meaning depends on the value of the message member.
time
Specifies the time at which the message was posted.
pt
Specifies the cursor position, in screen coordinates, when the message was posted.

15,978

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧