Главная страница | назад





Article #17157: Broadcast a message

 Question and Answer Database
FAQ2157C.txt Broadcast a message
Category :Windows API
Platform :All
Product :C++Builder 1.x
Question:
How do I broadcast a message to all top level Windows?
Answer:
The Windows API function SendMessage() takes a 4 parameters. The
first is the window handle. To broadcast to all top level Windows, use
HWND_BROADCAST. The second parameter is the message itself, and then
the WParam and the LParam parameters for the given message. For the
WM_WININICHANGE message, wParam should be zero, and LParam should be
either the address of a null terminated section name that changed, or
nil if you want each window to examine all sections for the change.
Passing a null value is not recommended unless you have modified several
sections due to performance considerations.
void __fastcall TForm1::Button1Click(TObject *Sender)
{
char s[64];
StrCopy(s, "windows");
SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0, long(&s));
}
7/2/98 10:32:32 AM

Last Modified: 01-SEP-99