Delphi loading GIF animation to form the outermost layer interface approach

unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Memo1: TMemo;
    Label1: TLabel;
    Edit1: TEdit;
    Button1: TButton;
    procedure Button1Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

where
  Form1: TForm1;

implementation

uses
  Unit2;
{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
  OpenFrm(Top, Left, Width, Height);
end;

end.
View Code
unit Unit2;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes,
  Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls, Vcl.ExtCtrls;

type
  TForm2 = class(TForm)
    Image1: TImage;
    Timer1: thour;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
    FRet: Boolean;
  public
    { Public declarations }
  end;

function OpenFrm(Top, Left, Width, Height: Integer): Boolean;

implementation

uses
  GifImg;
{$R *.dfm}

function OpenFrm(Top, Left, Width, Height: Integer): Boolean;
var
  Form2: TForm2;
begin
  Result := False;
  Form2 := TForm2.Create(nil);
  try
    Form2.Width := (Width div 4) * 3;
    Form2.Height := Height div 2;
    Form2.Top := Top + ((Height - Form2.Height) div 2);
    Form2.Left := Left + ((Width - Form2.Width) div 2);
    Form2.ShowModal;
    Result := Form2.FRet;
  finally
    FreeAndNil(Form2);
  end;
end;

procedure TForm2.FormCreate(Sender: TObject);
begin
  Self.BorderStyle := bsNone;
  Image1.Align := alClient;

 // first put in a form TImage component: Image1; 
  Image1.Picture.LoadFromFile ( ' D: \ loadpic \ 1.gif ' );

// AnimationSpeed animation speed is set, the larger the value, the faster; 
  TGIFImage (Image1.Picture.Graphic) .AnimationSpeed: = 200 is ;
  TGIFImage(Image1.Picture.Graphic).Animate := True;
end;

end.
View Code

 

Guess you like

Origin www.cnblogs.com/studycode/p/11666042.html