SpashScreen with ProgressBar

Posted on 2007-09-28
Medium Priority
Last Modified: 2010-04-05
Hi again,

I have an application which has quite a few things to load at the beginner so I'm going to add a splash screen to it.
My question is: How do I make a splashscreen with a progressbar on it?


Question by:ST3VO
LVL 26

Expert Comment

by:Tomas Helgi Johannsson
ID: 19978506

This is just matter of creating a simple form with the desired info/image etc displayed on it
while loading.
Simple follow this example : http://www.swissdelphicenter.ch/torry/showcode.php?id=420
Then add the ProgressBar on the SplashForm and update it according to the load of your

   Tomas Helgi
LVL 18

Accepted Solution

Johnjces earned 2000 total points
ID: 19978979
I do all of my splash screen stuff in my .dpr file... the Delphi project file.

I create the splash screen, show and update it, then create my other forms, which may initialize "stuff" when  created,  (OnCreate event) delay the action so the progress bar doesn't move too quickly and then show my main form and close the splash screen. (Not all the forms listed are created at run time as some are created when needed and then freed).

Here is the dpr file.

program HonDahPMS;

  Pers in 'Pers.pas' {FPersonnel},
  FindEmp in 'FindEmp.pas' {FFind},
  PayrollEffDate in 'PayrollEffDate.pas' {FPayrollEffDate},
  Logon in 'Logon.pas' {FLogon},
  Crypt32 in 'Crypt32.pas',
  Permissions in 'Permissions.pas' {FPermissions},
  DatCalc in 'DatCalc.pas' {FDateCalc},
  SQLChk in 'SQLChk.pas' {FSQLCheck},
  DBInfoCode in 'DBInfoCode.pas' {FDBInfo},
  backupdb in 'backupdb.pas' {FBackUp},
  restoredb in 'Restoredb.pas' {FRestore},
  about in 'about.pas' {AboutBox},
  AnnLvLiab in 'AnnLvLiab.pas' {FAnnLvLiab},
  errorform in 'errorform.pas' {FErrorForm},
  FutureLeave in 'FutureLeave.pas' {FFutureLv},
  PickLists in 'PickLists.pas' {FPickLists},
  TribalRep in 'TribalRep.pas' {FTribalRpt},
  PersSummary in 'PersSummary.pas' {FPersSummary},
  copychartclp in 'copychartclp.pas' {FCopyChartClp},
  TrainSum in 'TrainSum.pas' {FTrainSum},
  Splash in 'Splash.pas' {FSplash},
  Closing in 'Closing.pas' {FClosing},
  Attend in 'Attend.pas' {FAttendance},
  AnnivReport in 'AnnivReport.pas' {FAnnivReport},
  MIS in 'MIS.pas' {FMISInfo},
  ListEmp in 'ListEmp.pas' {FListEmp},
  RandList in 'RandList.pas' {FRandList},
  Relative in 'Relative.pas' {FRelatives},
  SingleBCMain in 'SingleBCMain.pas' {FSingleBC},
  BarCodeMain in 'BarCodeMain.pas' {FBarcode},
  Recog in 'Recog.pas' {FRecognition},
  EmpSignInOut in 'EmpSignInOut.pas' {FSignInOut},
  SvcErrors in 'SvcErrors.pas' {FSvcErrors};

{$R *.RES}

 FSplash := TFSplash.Create(Application);

// FSplash.ProgressBar1.StepIt;
 FSplash.Label5.Caption := 'Creating Main Form';
 FSplash.Label5.Caption := 'Connecting to SQL Server';

// FSplash.ProgressBar1.StepIt;
 Application.Title := 'HonDahPMS';
 Application.CreateForm(TFPersonnel, FPersonnel);

  //Application.CreateForm(TFSvcErrors, FSvcErrors);

 FSplash.Label5.Caption := 'Creating Form Find';

  Application.CreateForm(TFFind, FFind);

 FSplash.Label5.Caption := 'Creating Form Payroll';

  Application.CreateForm(TFPayrollEffDate, FPayrollEffDate);

 FSplash.Label5.Caption := 'Creating Form Logon';

  Application.CreateForm(TFLogon, FLogon);

 FSplash.Label5.Caption := 'Creating Form Permissions';

  Application.CreateForm(TFPermissions, FPermissions);

 FSplash.Label5.Caption := 'Creating ErrorForm';

  Application.CreateForm(TFErrorForm, FErrorForm);

 FSplash.Label5.Caption := 'Creating Form FutureLv';

  Application.CreateForm(TFFutureLv, FFutureLv);

 FSplash.Label5.Caption := 'Creating Form Relatives';

  Application.CreateForm(TFRelatives, FRelatives);

 FSplash.Label5.Caption := 'Creating Form SingleBC';

  Application.CreateForm(TFSingleBC, FSingleBC);

 FSplash.Label5.Caption := 'Creating Form Barcode';

  Application.CreateForm(TFBarcode, FBarcode);

 FSplash.Label5.Caption := 'Creating Form Recognition';

  Application.CreateForm(TFRecognition, FRecognition);

 FSplash.Label5.Caption := 'Creating Sign In/Out Log Date Set';

 Application.CreateForm(TFSignInOut, FSignInOut);

 FSplash.Label5.Caption := 'Finished Creating Forms!';


Now my delay routine is in the FSplash form.

Procedure TFSplash.Delay(MSecs: Cardinal);
 FirstTick, CurrentTick : Cardinal;
 Done : Boolean;
 Done := FALSE;
 FirstTick := GetTickCount;
 While Not Done do
   CurrentTick := GetTickCount;
   If Int64(CurrentTick) - Int64(FirstTick) < 0 Then
     If CurrentTick >= (Int64(FirstTick) - High(Cardinal) + MSecs) Then
      Done := TRUE;
         If CurrentTick - FirstTick >= MSecs Then
          Done := TRUE;

I also change the mouse cursor during the splash screen presentation in the Form show and return it to default in the Form hide portion of the Splash Screen.

procedure TFSplash.FormShow(Sender: TObject);
 Screen.Cursor := crAppStart;

procedure TFSplash.FormHide(Sender: TObject);
 Screen.Cursor := crDefault;

Lastly, in my main form in the OnShow, I hide then close the Splash Screen and show my logon prompt.

procedure TFPersonnel.FormShow(Sender: TObject);

A lot of steps, but makes for a pretty good splash screen with a progress bar. There are other ways and in another app I do everything in the FSplash. Load all of the other forms etc and have the the DPR only load and creaet the Splash Screen.

There are a lot of ways to do it, but the main thing is to create and show your spalsh screen in your dpr.

I hope this helped you out and gave you a good starting point.


Author Comment

ID: 19979085
Perfect. Thanks!!!

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
When cloud platforms entered the scene, users and companies jumped on board to take advantage of the many benefits, like the ability to work and connect with company information from various locations. What many didn't foresee was the increased risk…
Suggested Courses
Course of the Month13 days, 9 hours left to enroll

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question