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

2018-06-17 18:55:55来源:未知 阅读 ()

新老客户大回馈,云服务器低至5折

unit Unit1;

interface

uses
  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.

  

标签:

版权申明:本站文章部分自网络,如有侵权,请联系:west999com@outlook.com
特别注意:本站所有转载文章言论不代表本站观点,本站所提供的摄影照片,插画,设计作品,如需使用,请与原作者联系,版权归原作者所有

上一篇:DBGridEh的data group的使用(转)

下一篇:Delphi主窗体实现透明