在工程文件中代码如下:
program Project1;
uses
Forms,
Unit1 in 'Unit1.pas' {Form1},
Unit2 in 'Unit2.pas' {Form2};
{$R *.RES}
begin
Application.Initialize; {程序初始化}
Form2 := TForm2.Create(Application); {建立徽标Form}
Form2.Show; {显示徽标Form}
Form2.Update; {重画徽标Form,确保其中的图片被显示出来}
Application.CreateForm(TForm1, Form1); {建立主Form}
Form2.Hide; {隐藏徽标Form,使主Form显示出来}
Form2.Free; {释放徽标Form占用的资源}
Application.Run; {程序运行}
end.
在主Form的OnCreate事件处理过程中我们用一些延时代码来模拟耗时的初始化工作,
这样可以更清楚地看到Form2显示并停留数秒,直到主Form的OnCreate事件处理过程
执行完毕后自动消失。
Unit1.pas unit unit1;
interface
uses
Windows, Messages, SysUtils,
Classes, Graphics, Controls,
Forms, ExtCtrls;
type
TForm1 = class(TForm)
procedure FormCreate(Sender: TObject);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
{ OnCreate事件处理过程,延时五秒 }
procedure TForm1.FormCreate(Sender: TObject);
var
CurrTime: TSystemTime;
Sec: Word;
begin
GetSystemTime(CurrTime);
Sec := CurrTime.wSecond + 5;
while Sec>CurrTime.wSecond do
GetSystemTime(CurrTime);
end;
end.