现在的位置: 首页 > 综合 > 正文

在VC中 添加响应自定义消息

2013年10月05日 ⁄ 综合 ⁄ 共 480字 ⁄ 字号 评论关闭

参考了下面文章

 

http://www.builder.com.cn/2007/1016/558779.shtml

 

其中消息定义可以放在stdafx.h 文件中。

 

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

#define WM_DEBUG WM_USER + 1999

  2. 在窗口头文件中添加

class CStreamServerDlg : public CDialog
{
// Generated message map functions
//}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()

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

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

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

抱歉!评论已关闭.