posts - 14, comments - 4, trackbacks - 0, articles - 0

在VC中添加响应自定义的消息的代码步骤

Posted on 2006-07-02 18:00 will 阅读(250) 评论(0)  编辑 收藏 引用 所属分类: 技术探索

1. 首先定义一个消息代码

#define WM_DEBUG     WM_USER + 1999

2. 在窗口头文件中添加

class CStreamServerDlg : public CDialog
{
 // Generated message map functions
 //{{AFX_MSG(CStreamServerDlg)
...
 //}}AFX_MSG
 afx_msg void OnDebug(WPARAM wParam, LPARAM lParam); 
...
}

3. 在窗口的cpp文件中添加


BEGIN_MESSAGE_MAP(CStreamServerDlg, CDialog)
...
 ON_MESSAGE(WM_DEBUG, OnDebug)
END_MESSAGE_MAP()

LRESULT  CStreamServerDlg::OnDebug(WPARAM wParam, LPARAM lParam)
{
}

4. 其他地方就可以发送消息

pWnd->PostMessage(WM_DEBUG,  (WPARAM)p, 0) )


说明:

#define ON_MESSAGE(message, memberFxn)
{ message, 0, 0, 0, AfxSig_lwl,
(AFX_PMSG)(AFX_PMSGW)(LRESULT (AFX_MSG_CALL CWnd::*)(WPARAM, LPARAM))&memberFxn },



只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理