⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 splashfrm.~pas

📁 《Delphi实例开发教程》源代码包说明
💻 ~PAS
字号:
unit SplashFrm;

interface

uses
  Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
  Dialogs, jpeg, ExtCtrls, StdCtrls;

type
  TfrmSplash = class(TForm)
    imgLogo: TImage;
    imgTemp: TImage;
    lblLoading: TLabel;
    procedure FormCreate(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
    procedure Curtain();
    procedure Expand();
    procedure Focus();
  end;

var
  frmSplash: TfrmSplash;
  ImgWidth,ImgHeight : Integer;
const
  Step=800;

implementation

{$R *.dfm}


//窗帘效果
procedure TfrmSplash.Curtain();
var
  i,j: Integer;
  Rect: TRect;
begin
  //显示动画
  for i := 1 to 50 do
  begin
    imgLogo.Picture := nil;
    for j :=0 to 8 do
    begin
      with Rect do
      begin
        Left := j*50;
        Right := j*50+i;
        Top := 0;
        Bottom := imgLogo.Height;
      end;
      imgLogo.Canvas.CopyRect(Rect,imgTemp.Canvas,Rect);
    end;
    imgLogo.Refresh;
    Sleep(Step div 20);
  end;
  end;


   //中间扩展效果
  procedure TfrmSplash.Expand();
  var
  i : Integer;
  Rect : TRect;
begin
  for i := 0 to Step do
  begin
    with Rect do
    begin
      Left := Round(ImgWidth/2-(ImgWidth/2/Step)*i);
      Right := Round(ImgWidth/2+(ImgWidth/2/Step)*i);
      Top := Round(ImgHeight/2-(ImgHeight/2/Step)*i);
      Bottom := Round(ImgHeight/2+(ImgHeight/2/Step)*i);
    end;
    imgLogo.Picture := nil;
    imgLogo.Canvas.CopyRect(Rect,imgTemp.Canvas,Rect);
   imgLogo.Refresh;
  end;

  end;


  //聚焦效果
  procedure TfrmSplash.Focus();
  var
  i : Integer;
  Rect : TRect;
begin
  for i := 0 to Step do
  begin
    imgLogo.Picture := nil;
    //左
    with Rect do
    begin
      Left := 0;
      Right := Round((ImgWidth/2/Step)*i);
      Top := 0;
      Bottom := ImgHeight;
    end;
    imgLogo.Canvas.CopyRect(Rect,imgTemp.Canvas,Rect);
    //右
    with Rect do
    begin
      Left := Round(ImgWidth-(ImgWidth/2/Step)*i);
      Right := ImgWidth;
      Top := 0;
      Bottom := ImgHeight;
    end;
    imgLogo.Canvas.CopyRect(Rect,imgTemp.Canvas,Rect);
    //上
    with Rect do
    begin
      Left := 0;
      Right := ImgWidth;
      Top := 0;
      Bottom := Round((ImgHeight/2/Step)*i);
    end;
    imgLogo.Canvas.CopyRect(Rect,imgTemp.Canvas,Rect);
    //下
    with Rect do
    begin
      Left := 0;
      Right := ImgWidth;
      Top := Round(ImgHeight-(ImgHeight/2/Step)*i);
      Bottom := ImgHeight;
    end;
   imgLogo.Canvas.CopyRect(Rect,imgTemp.Canvas,Rect);
    imgLogo.Refresh;
  end;

  end;


  procedure TfrmSplash.FormCreate(Sender: TObject);
begin
//把imgLogo的图象赋给ImgTemp
  imgTemp.Picture.Assign(imgLogo.Picture);
  //显示Form
  Show;
  Refresh;
 ImgWidth := imgLogo.Picture.Width;
  ImgHeight := imgLogo.Picture.Height;
  randomize;
  case random(99) mod 3 of
  0: Curtain;
  1:Expand;
  2:focus;
end;

end;

end.

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -