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

📄 splash.pas

📁 免费控件PicShow的最新版本
💻 PAS
字号:
// If forms of your application appears fast on the screen, the splash of the
// other demo is better. In this example, because ADOConnection is slow, I used
// the following way to show the splash screen.

unit Splash;

interface

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

type
  TSplashForm = class(TForm)
    PicShow: TPicShow;
    procedure PicShowProgress(Sender: TObject);
  private
    procedure Init;
  public
    class procedure ShowSplash;
    class procedure HideSplash;
  end;

implementation

{$R *.DFM}

var
  SplashForm: TSplashForm;

function CaptureScreen(Left, Top, Width, Height: Integer): TBitmap;
var
  DC: HDC;
begin
  // We create a bitmap object for storing the screen behind the form.
  Result := TBitmap.Create;
  Result.Width := Width;
  Result.Height := Height;
  // We get device context of the screen and copy the screen behind the form
  // to the created bitmap.
  DC := GetDC(0);
  try
    BitBlt(Result.Canvas.Handle, 0, 0, Width, Height, DC, Left, Top, SRCCOPY);
  finally
    ReleaseDC(0, DC);
  end;
end;

procedure TSplashForm.Init;
var
  Scr: TBitmap;
begin
  // First we set position of the form on the center of desktop.
  // We set Position property of the form to poDesigned because we
  // need the form's position before showing it.
  Left := (Screen.Width - Width) div 2;
  Top := (Screen.Height - Height) div 2;
  // Then to give a transparent look to picshow, we capture the screen image
  Scr := CaptureScreen(Left, Top, Width, Height);
  try
    // and assign it to PicShow's background
    PicShow.BgPicture.Assign(Scr);
    // To reduce chance of flickering (only when PicShow is used as non-windowed
    // control we may sometime have flickers) we set background color of the form
    // to color of upper left pixel of the captured screen.
    Color := Scr.Canvas.Pixels[0,0];
  finally
    // We don't need the bitmap object, so we free it.
    Scr.Free;
  end;
  // Selects randomly a transition effect.
  Randomize;
  PicShow.Style := Random(High(TShowStyle)) + 1;
end;

class procedure TSplashForm.ShowSplash;
begin
  if SplashForm = nil then
  begin
    SplashForm := TSplashForm.Create(nil);
    SplashForm.Init;
    SplashForm.Show;
    SplashForm.Update;
    SplashForm.PicShow.Execute;
  end;
end;

class procedure TSplashForm.HideSplash;
begin
  if SplashForm <> nil then
  begin
    SplashForm.PicShow.Reverse := True;
    SplashForm.PicShow.Manual := False;
    SplashForm.Free;
    SplashForm := nil;
    Sleep(500);
  end;
end;

procedure TSplashForm.PicShowProgress(Sender: TObject);
begin
  if PicShow.Progress = 100 then
  begin
    PicShow.Style := Random(High(TShowStyle)) + 1;
    PicShow.Manual := True;
  end;
end;

end.

⌨️ 快捷键说明

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