利用FMX控件的MakeScreenshot过程实现WAIT效果

原理:

 1、新建一个waitform,添加控件:

    背景图片BACKPIC:Timage控件;

    再叠加一个WAIT图标(TAniIndicato控件)。

 2、在要实现wait效果的form上添加一个控件作为背景工作区(例如TPANEL)。

    需要实现wait效果时,调用TPANEL.MakeScreenshot,替换waitform上的BACKPIC,显示WAIT图标。

    结束时,关闭waitform。

关键代码如下:

unit waitform;

interface

uses......;

type

Twaitform= class(TForm)
   WorkingPanel: TRectangle;
   GrayBox: TRectangle;
   WorkingLBL: TLabel;
   AniIndicator: TAniIndicator;
   bgImage: TImage;
private
{ Private declarations }
public
{ Public declarations }
end;

调用主程序:

procedure  waitingMsg(Text: String; Working: Boolean);

begin
if Working=True then
begin
Application.ProcessMessages;
{$IFDEF ANDROID}
waitform.bgImage.Bitmap.Assign(PANEL1.MakeScreenshot);
{$ENDIF}
waitform.Show;
waitform.AniIndicator.Enabled := True;
waitform.WorkingLBL.Text := Text;
end
else
begin
waitform.AniIndicator.Enabled := False;
waitform.WorkingLBL.Text := Text;
waitform.Close;
{$IFDEF ANDROID}
waitform.bgImage.Bitmap.Assign(nil);
{$ENDIF}
mainform.Show;
end;
end;

procedure Tmainform.Button1Click(Sender: TObject);
begin
waitingMsg('wait...',True);
end;

    

原文地址:https://www.cnblogs.com/happyhills/p/3549003.html