首页 > 代码库 > 全局消息
全局消息
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
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
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
procedure WndProc(var Message: TMessage); override;
public
{ Public declarations }
end;
end;
var
Form1: TForm1;
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.FormCreate(Sender: TObject);
begin
begin
//注册一个系统级消息,消息名字最好独一无二,否则不能返回的消息id给msg变量
Msg := RegisterWindowMessage(‘WINDOWS_SYSTEM_TINGHUATONGFANGPC_DIGITALEDU_GQ‘);
Msg := RegisterWindowMessage(‘WINDOWS_SYSTEM_TINGHUATONGFANGPC_DIGITALEDU_GQ‘);
end;
procedure TForm1.WndProc(var Message: TMessage);
begin
if( Message.Msg = Msg) and (Message.WParam=1) then begin
Caption := ‘‘;
ShowMessage(‘收到消息了‘);
end
else begin
inherited;
end;
end;
begin
if( Message.Msg = Msg) and (Message.WParam=1) then begin
Caption := ‘‘;
ShowMessage(‘收到消息了‘);
end
else begin
inherited;
end;
end;
procedure TForm1.Button1Click(Sender: TObject);
var
M: TMessage;
B: DWord;
begin
M.Msg := Msg;
var
M: TMessage;
B: DWord;
begin
M.Msg := Msg;
//向整个PC发送全局消息
B := BSM_ALLCOMPONENTS;
B := BSM_ALLCOMPONENTS;
//(BSF_POSTMESSAGE表示使用POST方式发送
BroadcastSystemMessage(BSF_POSTMESSAGE, @B , M.Msg, 1, 0);
end;
BroadcastSystemMessage(BSF_POSTMESSAGE, @B , M.Msg, 1, 0);
end;
end.
全局消息
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。