RegisterWindowMessage函数(具体了解该函数可以查看百度或MSDN)
『http://msdn.microsoft.com/en-us/library/ms644947%28v=vs.85%29.aspx
http://baike.baidu.com/view/1464452.htm?fr=aladdin』
1.为了保证消息号在系统中唯一性,在全局".h"中定义一个RegisterWindowMessage ,
如:CONST UINT RWMESSAGE = RegisterWindowMessage(_T(" REGISTER WINDOWS MESSAGE");
2.BEGIN_MESSAGE_MAP在响应函数中添加响应函数,如:BEGIN_MESSAGE_MAP中添加想以函数
ON_REGISTERED_MESSAGE(RWMESSAGE, OnRwMessageWindow)
3.如:AfxGetApp()->GetMainWnd()->SendMessage(RWMESSAGE, (WPARAM)this );或
AfxGetApp()->GetMainWnd()->PostMessage(RWMESSAGE, (WPARAM)this ); ((WPARAM)this可以不发送过去,这为只发信号不传递参数)
发送消息,具体情况具体考虑getmainwnd()为向主窗口发送消息(postmessage或sendmessage具体要用哪个按实际情况使用)
4.接收消息:LRESULT OnRwMessageWindow(WPARAM wParam,LPARAM lParam)
{
/* WPARAM wParam 为专递过来的指针*/
CWnd *pWnd = (CWnd*)wParam;/*指针传值*/
if ( pWnd )/*指针是否传递过来*/
{
}
else{};
return 0;
}