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; var Form1: TForm1; implementation uses Unit2; {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin OpenFrm(Top, Left, Width, Height); end; end.
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: TTimer; 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; // 先在窗体上放一个 TImage 组件:Image1; Image1.Picture.LoadFromFile(‘d:\loadpic\1.gif‘); // AnimationSpeed 设定动画速度,值越大,速度越快; TGIFImage(Image1.Picture.Graphic).AnimationSpeed := 200; TGIFImage(Image1.Picture.Graphic).Animate := True; end; end.
原文:https://www.cnblogs.com/studycode/p/11666042.html