posts - 25, comments - 69, trackbacks - 0, articles - 2

vc中快速加入自定义消息

Posted on 2006-11-24 18:03 壮士日志 阅读(421) 评论(0)  编辑  收藏 所属分类: 编程技术

首先定义消息:

#define POST_DATA_START WM_USER+1
#define POST_DATA_END WM_USER+2
#define RECEIVE_DATA_START WM_USER+3
#define RECEIVE_DATA_END WM_USER+4
#define THREAD_START WM_USER+5
#define THREAD_END WM_USER+6
#define TASK_START WM_USER+7
#define TASK_END WM_USER+8
#define TASK_IDEL WM_USER+9

声明处理函数
 //{{AFX_MSG(CMyDlg)
 ........
 afx_msg void OnPostDataStart(WPARAM wParam, LPARAM lParam);
 afx_msg void OnPostDataEnd(WPARAM wParam, LPARAM lParam);
 afx_msg void OnReceiveDataStart(WPARAM wParam, LPARAM lParam);
 afx_msg void OnReceiveDataEnd(WPARAM wParam, LPARAM lParam);
 afx_msg void OnThreadStart(WPARAM wParam, LPARAM lParam);
 afx_msg void OnThreadEnd(WPARAM wParam, LPARAM lParam);
 afx_msg void OnTaskStart(WPARAM wParam, LPARAM lParam);
 afx_msg void OnTaskEnd(WPARAM wParam, LPARAM lParam);
 afx_msg void OnTaskIdel(WPARAM wParam, LPARAM lParam);
 //}}AFX_MSG
 DECLARE_MESSAGE_MAP()
注意所有函数声明都要在 DECLARE_MESSAGE_MAP()前面

绑定消息和处理函数:
BEGIN_MESSAGE_MAP(CMyDlg, CDialog)
//{{AFX_MSG_MAP(CMyDlg)
ON_MESSAGE(POST_DATA_START,OnPostDataStart)
ON_MESSAGE(POST_DATA_END,OnPostDataEnd)
ON_MESSAGE(POST_DATA_START,OnReceiveDataStart)
ON_MESSAGE(RECEIVE_DATA_START,OnReceiveDataEnd)
ON_MESSAGE(RECEIVE_DATA_END,OnThreadStart)
ON_MESSAGE(THREAD_START,OnThreadEnd)
ON_MESSAGE(TASK_END,OnTaskStart)
ON_MESSAGE(TASK_START,OnTaskEnd)
ON_MESSAGE(TASK_IDEL,OnTaskIdel)

//}}AFX_MSG_MAP
END_MESSAGE_MAP()

当然最后还要完成函数实体


只有注册用户登录后才能发表评论。


网站导航: