TAppCreateForm (Delphi)
Description
This example shows the progress of loading forms as an application starts up. The code example is placed in the project source (*.dpr) file. To see the project source, right-click the executable file in the Project Manager and select the View Source menu item. You will need to set up your project with the following steps before using the code example:
- Add four additional forms to a default project.
- Place a TProgressBar on Form5.
- Use the Project > Options > Forms menu option and place Form5 on the available forms list.
- Change the code of your project (*.dpr) file to look like the example.
Code
begin
Application.Initialize;
with TForm5.Create(nil) do
try
Application.MainFormOnTaskbar := True;
ProgressBar1.Max := 100;
Show; // show a splash screen contain ProgressBar control
Update; // force display of Form5
Application.CreateForm(TForm1, Form1);
ProgressBar1.StepBy(25);
Label1.Caption := 'Form1 loaded successfully.';
Update; // force display of Form5
Sleep(3000);
Application.CreateForm(TForm2, Form2);
ProgressBar1.StepBy(25);
Label1.Caption := 'Form2 loaded successfully.';
Update; // force display of Form5
Sleep(3000);
Application.CreateForm(TForm3, Form3);
ProgressBar1.StepBy(25);
Label1.Caption := 'Form3 loaded successfully.';
Update; // force display of Form5
Sleep(3000);
Application.CreateForm(TForm4, Form4);
ProgressBar1.StepBy(25);
Label1.Caption := 'Form4 loaded successfully.';
Update; // force display of Form5
Sleep(3000);
finally
Free;
end;
Application.Run;
Uses
- Vcl.Forms.TApplication.CreateForm ( fr | de | ja )
- Vcl.ComCtrls.TProgressBar.StepBy ( fr | de | ja )
- Vcl.Forms.TApplication.Run ( fr | de | ja )
- Vcl.Forms.TCustomForm.Show ( fr | de | ja )
- Vcl.Controls.TWinControl.Update ( fr | de | ja )
- Vcl.Forms.TApplication.Initialize ( fr | de | ja )
- Vcl.Forms.TApplication.MainFormOnTaskBar ( fr | de | ja )