zoukankan      html  css  js  c++  java
  • Delphi 加载GIF动画到界面窗体最外层处理方法

    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.
    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: 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:loadpic1.gif');
    
    // AnimationSpeed 设定动画速度,值越大,速度越快;
      TGIFImage(Image1.Picture.Graphic).AnimationSpeed := 200;
      TGIFImage(Image1.Picture.Graphic).Animate := True;
    end;
    
    end.
    View Code

  • 相关阅读:
    第十周上机作业
    第九周上机作业
    第八周作业
    第八周上机作业
    第七周作业
    第七周上机作业
    第六周作业
    第六周上机作业
    第五周上机作业
    第四周作业
  • 原文地址:https://www.cnblogs.com/studycode/p/11666042.html
Copyright © 2011-2022 走看看