TAppCreateForm (C++)
Description
This example shows the progress of loading forms as an application starts up. The code example is placed in the project source (*_proj.cpp) file. To see the project source, right-click the executable file in the Project Manager and select the View Source menu item. You 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 (*_proj.cpp) file to look like the example.
Code
#include <vcl.h>
#include "Unit5.h"
#pragma hdrstop
//---------------------------------------------------------------------------
USEFORM("TAppCreateForm.cpp", Form1);
USERES("Project1.res");
USEFORM("Unit2.cpp", Form2);
USEFORM("Unit3.cpp", Form3);
USEFORM("Unit4.cpp", Form4);
USEFORM("Unit5.cpp", Form5);
//---------------------------------------------------------------------------
WINAPI WinMain(HINSTANCE, HINSTANCE, LPSTR, int)
{
try
{
Application->Initialize();
Application->MainFormOnTaskBar = true;
Application->CreateForm(__classid(TForm5), &Form5);
Form5->ProgressBar1->Max = 100;
Form5->Show(); // Show a splash screen containing ProgressBar control.
Form5->Update(); // Force the display of Form5.
Application->CreateForm(__classid(TForm1), &Form1);
Form5->ProgressBar1->StepBy(25);
Form5->Label1->Caption = "Form1 loaded successfully.";
Form5->Update(); // Force the display of Form5.
Sleep(3000);
Application->CreateForm(__classid(TForm2), &Form2);
Form5->ProgressBar1->StepBy(25);
Form5->Label1->Caption = "Form2 loaded successfully.";
Form5->Update(); // Force the display of Form5.
Sleep(3000);
Application->CreateForm(__classid(TForm3), &Form3);
Form5->ProgressBar1->StepBy(25);
Form5->Label1->Caption = "Form3 loaded successfully.";
Form5->Update(); // Force the display of Form5.
Sleep(3000);
Application->CreateForm(__classid(TForm4), &Form4);
Form5->ProgressBar1->StepBy(25);
Form5->Label1->Caption = "Form4 loaded successfully.";
Form5->Update(); // Force the display of Form5.
Sleep(3000);
// delete Form5;
Application->Run();
}
catch (Exception &exception)
{
Application->ShowException(&exception);
}
return 0;
}
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 )