WTL 出现的SetMsgHandled和IsMsgHandled 错误
WTL 出現的SetMsgHandled和IsMsgHandled 錯誤
江西理工 FangSH 2010/8/26
在學WTL第二部界面基類時程序出現了一個錯誤 如下:
mainfrm.cpp
e:\編程文檔\wtl\wtl_study_fangsh\wtlclock\mainfrm.h(37) : error C2065: 'SetMsgHandled' : undeclared identifier
e:\編程文檔\wtl\wtl_study_fangsh\wtlclock\mainfrm.h(37) : error C2065: 'IsMsgHandled' : undeclared identifier
Generating Code...
Compiling...
WTLClock.cpp
e:\編程文檔\wtl\wtl_study_fangsh\wtlclock\mainfrm.h(37) : error C2065: 'SetMsgHandled' : undeclared identifier
e:\編程文檔\wtl\wtl_study_fangsh\wtlclock\mainfrm.h(37) : error C2065: 'IsMsgHandled' : undeclared identifier
錯誤定位到:
?
?
網有一些說法 試好久都沒能改過來。幸好在有一個外國網站http://www.hydrogenaudio.org/forums/lofiversion/index.php/t78967.html 發現了自己的問題原來
?????? BEGIN_MSG_MAP(CMainFrame)
????????????? ……
?????? END_MSG_MAP()
應該是
?????? BEGIN_MSG_MAP_EX(CMainFrame)
????????????? ……
?????? END_MSG_MAP()
MFC程序員的WTL指南——界面基類中WTL 對消息映射的增強說到:
將Win32 API通過消息傳遞過來的WPARAM和LPARAM數據還原出來是一件麻煩的事情并且很容易出錯,不幸得是ATL并沒有為我們提供更多的幫助,我們仍然需要從消息中還原這些數據,當然WM_COMMAND和WM_NOTIFY消息除外。但是WTL的出現拯救了這一切!
WTL的增強消息映射宏定義在atlcrack.h中。(這個名字來源于“消息解密者”,是一個與windowsx.h的宏所使用的相同術語)首先將BEGIN_MSG_MAP改為BEGIN_MSG_MAP_EX,帶_EX的版本產生“解密”消息的代碼。
而另一種方法是:在stdafx.h文件得結尾處添加這兩行代碼來解決這個問題:
#undef BEGIN_MSG_MAP
#define BEGIN_MSG_MAP(x) BEGIN_MSG_MAP_EX(x)
?
是我自己太粗心了…………
?
轉載于:https://www.cnblogs.com/fangshenghui/archive/2010/08/26/1809340.html
總結
以上是生活随笔為你收集整理的WTL 出现的SetMsgHandled和IsMsgHandled 错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: C/C++ 电子书推荐
- 下一篇: [转]SAP FI/CO 模块设置