unit uShowInfo; interface uses System.SysUtils, System.Types, System.UITypes, System.Classes, System.Variants, FMX.Types, FMX.Controls, FMX.Forms, FMX.Graphics, FMX.Dialogs, FMX.ImgList, FMX.Objects, System.ImageList; type TFrmShowInfo = class(TForm) Glyph22: TGlyph; TxtInfo: TText; Text3: TText; ImageList1: TImageList; Rectangle8: TRectangle; Rectangle4: TRectangle; procedure Text2Click(Sender: TObject); procedure Text1Click(Sender: TObject); private { Private declarations } public { Public declarations } end; var FrmShowInfo: TFrmShowInfo; function ShowInfoOKCancel(sInfo:string):boolean; function ShowError(sInfo:string):boolean; function ShowInfoOK(sInfo:string; IsQualified: Boolean):boolean; implementation {$R *.fmx} function ShowInfoOKCancel(sInfo:string):boolean; begin Result:=false; with TFrmShowInfo.Create(nil) do begin try TxtInfo.Text:=sInfo; Result:=ShowModal=MrOk; finally Free; end; end; end; function ShowError(sInfo:string):boolean; begin with TFrmShowInfo.Create(nil) do begin try Text3.Text:='错误'; TxtInfo.Text:=sInfo; Glyph22.ImageIndex:=1; Rectangle4.Visible:=false; Result:=ShowModal=MrOk; finally Free; end; end; end; //function ShowInfoOK(sInfo:string):boolean; //begin // with TFrmShowInfo.Create(nil) do // begin // try // TxtInfo.Text:=sInfo; // Rectangle4.Visible:=false; // Result:=ShowModal=MrOk; // finally // Free; // end; // end; //end; function ShowInfoOK(sInfo: string; IsQualified: Boolean): Boolean; var Form: TFrmShowInfo; begin Form := TFrmShowInfo.Create(nil); try Form.TxtInfo.Text := sInfo; Form.Rectangle4.Visible := False; if IsQualified then begin TThread.CreateAnonymousThread( procedure begin Sleep(1000); TThread.Synchronize(nil, procedure begin // 使用 Synchronize 不需要额外的检查 Form.ModalResult := mrOk; end); end).Start; end; Result := Form.ShowModal = mrOk; finally Form.Free; end; end; procedure TFrmShowInfo.Text1Click(Sender: TObject); begin ModalResult:=mrOK; end; procedure TFrmShowInfo.Text2Click(Sender: TObject); begin ModalResult:=mrCancel; end; end.