[问题提出] 在程序中,要完成自己独特的任务,必须自己来定义消息.如何做呢? [解决方法] 1)定义自己的消息,要从WM_USER开始. #define WM_MY_MESSAGE WM_USER+10 2)定义自己的消息映射关系. BEGIN_MESSAGE_MAP(CMainFrame,CFrameWnd) ON_MESSAGE(WM_MY_MESSAGE,OnMyMessage) END_MESSAGE_MAP() 3)编写OnMyMessage() LRESULT CMainFrame::OnMyMessage(WPARAM wParam,LPARAM lParam) { ......... return 0;//自己决定. } [具体程序实现例子] 在.h中: class CMainFrame : public CFrameWnd { public: LRESULT OnMyMessage(WPARAM wParam,LPARAM lParam); ........ }; 在.cpp中 #include "MainFrm.h" ...... #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif ......//上面都是系统的 #define WM_MY_MESSAGE WM_USER+10 ..... LRESULT CMainFrame::OnMyMessage(WPARAM wParam,LPARAM lParam) { ..... return 0; } |
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交