Hi,
I am trying to send HWND_BROADCAST message (this is some kind of signal which is sended to all top windows) but this works only with SendMessage but documentation say that is should works with PostMessage too:
http://msdn.microsoft.com/en-us/library/ms644944(v=vs.85).aspxAnd this is my code:
Application 1 (sender)
uses windows;
var
FMsg: UINT;
begin
FMsg := RegisterWindowMessage('my_test_message');
// Works
windows.SendMessage(HWND_BROADCAST, FMsg, 1, 0);
// Doesn't work
//windows.PostMessage(HWND_BROADCAST, FMS, 1, 0);
end;
Application 2 (Receiver)
uses windows;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
{ private declarations }
MsgSignals: UINT;
protected
procedure WndProc(var TheMessage: TLMessage); override;
public
{ public declarations }
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
MsgSignals := RegisterWindowMessage('my_test_message');
end;
procedure TForm1.WndProc(var TheMessage: TLMessage);
begin
if TheMessage.msg=MsgSignals then
Memo1.Append('WParam: '+IntToStr(TheMessage.wParam));
inherited WndProc(TheMessage);
end;
I could leave SendMessage but it waiting for processing. Any idea? Is this a bug?
Regards
Stable Lazarus 0.9.30, FPC 2.4.2. Windows 7 32bit