学习官方示例 - TApplication.CreateForm

本例源码下载, 运行效果图:

学习官方示例 - TApplication.CreateForm

制作过程:
1、新建工程后, 再添加 Form2、Form3、Form4、Form5;
2、在 Form5 上分别添加一个 TProgressBar、TLabel(使用默认名称);
3、打开工程源码(Project -> View Source), 贴入以下文件后运行.

program Project1;



uses

  Forms,

  SysUtils,

  Unit1 in 'Unit1.pas' {Form1},

  Unit2 in 'Unit2.pas' {Form2},

  Unit3 in 'Unit3.pas' {Form3},

  Unit4 in 'Unit4.pas' {Form4},

  Unit5 in 'Unit5.pas' {Form5};



{$R *.res}



begin

  Application.Initialize;

  with TForm5.Create(nil) do

  try

    Application.MainFormOnTaskbar := True;

    Position := poDesktopCenter;

    ProgressBar1.Max := 100;

    Show;

    Update;

    Sleep(1000);

    Application.CreateForm(TForm1, Form1);

    Form1.Position := poDesktopCenter;

    ProgressBar1.StepBy(25);

    Label1.Caption :=  'Form1 loaded successfully.';

    Update;

    Sleep(1000);

    Application.CreateForm(TForm2, Form2);

    ProgressBar1.StepBy(25);

    Label1.Caption :=  'Form2 loaded successfully.';

    Update;

    Sleep(1000);

    Application.CreateForm(TForm3, Form3);

    ProgressBar1.StepBy(25);

    Label1.Caption :=  'Form3 loaded successfully.';

    Update;

    Sleep(1000);

    Application.CreateForm(TForm4, Form4);

    ProgressBar1.StepBy(25);

    Label1.Caption :=  'Form4 loaded successfully.';

    Update;

    Sleep(1000);

  finally

    Free;

  end;

  Application.Run;

end.


 
   

你可能感兴趣的:(application)