FMX有一套自己的消息处理机制。类似这样:

2017-09-29 19:31:05来源:cnblogs.com作者:涂磊人点击

分享
unit Unit1;interfaceuses  System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants,  FMX.Presentation.Messages,  FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs,  FMX.Controls.Presentation, FMX.StdCtrls;type  TForm1 = class(TForm)    Button1: TButton;    procedure FormCreate(Sender: TObject);    procedure Button1Click(Sender: TObject);    procedure FormDestroy(Sender: TObject);  private    { Private declarations }    FMessageSender: TMessageSender;  public    { Public declarations }    procedure DefaultHandler(var Message); override;  end;var  Form1: TForm1;implementation{$R *.fmx}procedure TForm1.Button1Click(Sender: TObject);begin  FMessageSender.SendMessage(10, 'aaa');end;procedure TForm1.DefaultHandler(var Message);begin  inherited;  ShowMessage(TDispatchMessage(Message).MsgID.ToString());  ShowMessage(TDispatchMessageWithValue<String>(Message).Value);end;procedure TForm1.FormCreate(Sender: TObject);begin  FMessageSender := TMessageSender.Create();  FMessageSender.Receiver := Self;end;procedure TForm1.FormDestroy(Sender: TObject);begin  FMessageSender.DisposeOf();end;end.

  

最新文章

123

最新摄影

闪念基因

微信扫一扫

第七城市微信公众平台