[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1719
  • Last Modified:

Broadcast WM_USER message

I would like to do something similar to BroadcastSystemMessage, but broadcast a message of type WM_USER+whatever.

BroadcastSystemMessage won't support message types above WM_USER. It says the user must do "custom marshalling". Does anybody know how to do this?

The only reason I can think of that it can't be done would be is another application responds to the same WM_USER message in a different way. I still would like to take my chances on this one.

MSDN reference: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/windowing/messagesandmessagequeues/messagesandmessagequeuesreference/messagesandmessagequeuesfunctions/postmessage.asp
0
rbohac
Asked:
rbohac
  • 3
2 Solutions
 
mokuleCommented:
Hi,
You should first use RegisterWindowMessage in any application to communicate.
0
 
SaLzCommented:
unit Unit1;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    WM_BroadCast: DWord;
    procedure WndProc(var Message: TMessage); override;
  end;

var
  Form1: TForm1;  

implementation

{$R *.dfm}

{ TForm1 }

procedure TForm1.WndProc(var Message: TMessage);
begin
  if Message.Msg = WM_BroadCast then
    ShowMessage('Angekommen')
  else
    inherited;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
  BroadcastSystemMessage(BSF_FORCEIFHUNG or BSF_POSTMESSAGE, nil, WM_BroadCast, 0, 0);
end;

procedure TForm1.FormCreate(Sender: TObject);
begin
  WM_BroadCast := RegisterWindowMessage('WM_BroadCast');
end;

end.
0
 
rbohacAuthor Commented:
Interesting. Thanks, I will give that a try this afternoon.
0

Featured Post

Prep for the ITIL® Foundation Certification Exam

December’s Course of the Month is now available! Enroll to learn ITIL® Foundation best practices for delivering IT services effectively and efficiently.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now