TAppCreateForm (Delphi)

From RAD Studio Code Examples
Jump to: navigation, search

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:

  1. Add four additional forms to a default project.
  2. Place a TProgressBar on Form5.
  3. Use the Project > Options > Forms menu option and place Form5 on the available forms list.
  4. 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