标签:static over including sys stat nbsp ESS 可见 system
HWND_BROADCAST可以在窗口之间广播消息
在MSDN中的描述:
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.
这个消息可以发送给Windows系统所有的顶层窗口,包括禁用或不可见的未拥有窗口、重叠窗口、弹出窗口,子窗口除外。
1.首先定义消息
static UINT WM_ADDR = RegisterWindowMessage(_T("WM_ADDR"));
注意:发送端和接收端都需要注册此消息。
2.其次处理消息
发送端,例如:
::PostMessage(HWND_BROADCAST, WM_ADDR, 0, 0);或
::SendMessage(HWND_BROADCAST, WM_ADDR, 0, 0);
接收端,例如:
宏声明如下:
ON_REGISTERED_MESSAGE(WM_ADDR, OnAddr);
函数声明:
LRESULT OnAddr(WPARAM wParam, LPARAM lParam);
函数定义:
LRESULT CDlg::OnAddr(WPARAM wParam, LPARAM lParam)
{
return 0;
}
这样不通过窗口句柄就可以在窗口之间发送消息。
标签:static over including sys stat nbsp ESS 可见 system
原文地址:https://www.cnblogs.com/sooksjb/p/9272891.html