Delivery message (send and receive system messages)

zhaozj2021-02-11  145

{2002.07.22 on how to send and receive system messages Author: Wang Zhen Yi nickname: LargeWang (Pharaoh) QQ: 33728007 Welcome Peng industry software www.pengesoft.com.cn

The following code Delphi7.0 passes, launch two processes after compiling, and then click Button1 in a window. }

Unit unit1;

Interface

Uses Windows, Messages, Sysutils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls;

type TForm1 = class (TForm) Button1: TButton; procedure FormCreate (Sender: TObject); procedure Button1Click (Sender: TObject); private Msg: LongInt; {Private declarations} protected procedure WndProc (var Message: TMessage); override; public

{Public declarations} END;

Var Form1: TFORM1;

IMPLEMentation

{$ R * .dfm}

Procedure TForm1.FormCreate (Sender: TOBJECT); Begin Msg: = RegisterWindowMessage ('WM_MYMESSAGE'); Self.Bringtofront; End;

Procedure TForm1.WndProc (Var Message: TMessage); begin if message.msg = msg dam caption: = '; showMessage (' received message "); end; end;

procedure TForm1.Button1Click (Sender: TObject); var M: TMessage; B: DWord; begin M.Msg: = Msg; B: = BSM_ALLCOMPONENTS; BroadcastSystemMessage (BSF_POSTMESSAGE, @B, M.Msg, M.WParam, M.LParam END;

End.

转载请注明原文地址:https://www.9cbs.com/read-5781.html

New Post(0)