比如多个菜单项共用同一个消息处理函数的时候,在这个函数中间怎么判断消息是从那个菜单项发送过来的?也就是如果这个处理函数没有wParam和lParam时,怎么在函数体中得到这两个参数?
谢谢!
谢谢!
解决方案 »
- 请问解析标签的算法是什么
- 对话框之间的数值传递问题
- 用VC如何访问远程的文件
- 如何在我线程函数中调用我主框家里的成员变量!马上在线给分
- 编译错误 can't open precompiled headerfiles:'debug 工程名.pck';no suchfile or directory 请问是什么意思?谢谢
- 求救:CMemFile与CArchive的使用
- 请教高手:线程问题!!!!!!
- vc入不了门,给一点建议。
- 新手该如何入手VC开发
- 求大神帮忙做一个有银行卡和取款机构成的系统
- 如何将窗口客户区的内容保存成一个BMP文件?要求不用MFC,用Windows API
- 请问谁有spy++ 软件或知道在哪下载的?请帮个忙谢谢!
Writing the Message-Map Entry
In the .CPP file, add your message-map entry, as shown in the following example:
...
BEGIN_MESSAGE_MAP(CMyApp, CWinApp)
//{{AFX_MSG_MAP(CMyApp)
...
//}}AFX_MSG_MAP
ON_COMMAND_RANGE(ID_MYCMD_ONE, ID_MYCMD_TEN, OnDoSomething)
END_MESSAGE_MAP( )2
Declaring the Handler Function
In the .H file, add your handler function declaration outside the //{{AFX_MSG comment brackets. The following code shows how this might look, as shown in the next-to-last line below:
// Generated message-map functions
protected:
//{{AFX_MSG(CMyApp)
...
//}}AFX_MSG
afx_msg void OnDoSomething( UINT nID );
DECLARE_MESSAGE_MAP()void CMyApp::OnDoSomething( UINT nID )
{
int nButton = nID - IDC_BUTTON1;
switch(nButton)
{
case....
}
// ...
}
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/HTML/_core_handlers_for_message.2d.map_ranges.asp
深入浅出MFC第2版 第147页