请问RegisterWindowMessage函数的干什么用的,什么时候使用?
还有下面代码是什么意思?
UINT nMsgID = RegisterWindowMessage(g_szCustomWndMsg);
PostMessage(HWND_BROADCAST, nMsgID, 0, 0);
HWND_BROADCAST是什么东东?麻烦解释一下,先谢了!!
还有下面代码是什么意思?
UINT nMsgID = RegisterWindowMessage(g_szCustomWndMsg);
PostMessage(HWND_BROADCAST, nMsgID, 0, 0);
HWND_BROADCAST是什么东东?麻烦解释一下,先谢了!!
解决方案 »
- CChildFrame 布局
- 模拟键盘
- 求MFC无模式对话框传值的详细例子!
- 如何强制删除一个正在使用的文件?????????????????????????再线等,马上解决,立刻给分,谢谢啊...............
- ocx中的cxxctrl类的一些问题
- 在windows下获得网卡状态。(急!在线等)
- 防火墙的实时监控是如何实现的??
- 系统钩子是什么东西?
- 大家一定要帮个忙,突然间**QQ在2000**不能用,(和2000本身有关)------------错误如下:
- 我想找一本MFC类库使用的手册???
- Image::Save保存图片后,为什么保存后的图片大小为0Kb?
- IMarkupServices::ParseString获取web内容编码问题
HWND_BROADCAST:The message is posted to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows. The message is not posted to child windows.
但是比如碰巧程序B要跟程序b1,b2通讯,不巧代码里也是用的消息0xC001,那么A程序PostMessage(HWND_BROADCAST,0xC001,就有问题了,因为这样b1,b2也会收到消息0xC001,而且他们
会以为是B发出的消息。
有了RegisterWindowMessage,程序A,a1,a2用一个字符串注册一个消息作为它们之间通讯的专用消息,比我我们使用GUID,这样可以保证与程序B,b1,b2使用的专用消息不
一样,这样广播消息就不会引起混乱。因为RegisterWindowMessage保证同一时刻用不同字符串注册消息会得到不同的消息,用同一字符串注册一定得到同一个消息。“不同字符串”可以很容易用GUID实现
比如修改注册表后,隐藏托盘图标后,都可以发送此消息:
// 刷新托盘
::SendMessage(HWND_BROADCAST, WM_SETTINGCHANGE, 0, 0);
UINT Msg,
WPARAM wParam,
LPARAM lParam
);
ParametershWnd
[in]
Handle to the window whose window procedure will receive the message. If this parameter is HWND_BROADCAST, the message is sent to all top-level windows in the system, including disabled or invisible unowned windows, overlapped windows, and pop-up windows; but the message is not sent to child windows.