在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
2、在要实现的unit中定义一个私有方法 procedure doMyMessage(var msg:TMessage);message WM_MyMessage; 3、实现这个私有方法 procedure TForm1.doMyMessage(var msg:TMessage); begin // if msg.Msg= WM_MyMessage then showmessage('好啊') else showmessage('不好');
end;
4、最重要 把这个消息广播出去 Form1.Perform(WM_MyMessage,0,0);
下面是实现的代码
unit Unit1;
interface
uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls; const WM_MyMessage=WM_USER+$200;
type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private procedure doMyMessage(var msg:TMessage);message WM_MyMessage; { Private declarations } public { Public declarations } end;
var Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.doMyMessage(var msg:TMessage); begin // if msg.Msg= WM_MyMessage then showmessage('好啊') else showmessage('不好');
end;
procedure TForm1.Button1Click(Sender: TObject);
begin Form1.Perform(WM_MyMessage,0,0);
end;
end. |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论