闪屏窗体。一个友好提示的窗体对话框。
//闪屏窗体 procedure ShowSplash(XX:string); begin SplashDlg:=TSplashDlg.Create(Application); SetWindowPos(SplashDlg.Handle,HWND_TOPMOST,0,0,0,0,SWP_NOMOVE or SWP_NOSIZE);//置前并且不得到焦点 SplashDlg.XX.Caption:=XX; SplashDlg.Show; end;
窗体代码如下
unit OPSplash; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, ExtCtrls; type TSplashDlg = class(TForm) XX: TLabel; Timer1: TTimer; Shape1: TShape; Shape2: TShape; Shape3: TShape; procedure FormCreate(Sender: TObject); procedure Timer1Timer(Sender: TObject); procedure FormClose(Sender: TObject; var Action: TCloseAction); procedure FormCloseQuery(Sender: TObject; var CanClose: Boolean); procedure FormShow(Sender: TObject); private ShowCount:Integer ; { Private declarations } public { Public declarations } end; var SplashDlg: TSplashDlg; implementation {$R *.dfm} procedure TSplashDlg.FormCreate(Sender: TObject); begin Top:=-6; ShowCount:=0; end; procedure TSplashDlg.Timer1Timer(Sender: TObject); begin ShowCount:=ShowCount+1; if ShowCount>3 then Close ; end; procedure TSplashDlg.FormClose(Sender: TObject; var Action: TCloseAction); begin Action:=caFree ; end; procedure TSplashDlg.FormCloseQuery(Sender: TObject; var CanClose: Boolean); begin AnimateWindow(handle,250,AW_HIDE+AW_VER_NEGATIVE); end; procedure TSplashDlg.FormShow(Sender: TObject); begin Width:=20+XX.Width+30; Left:=(Screen.WorkAreaWidth-width) div 2; AnimateWindow(handle,250,AW_VER_POSITIVE); //渐变 end; end.