SpashScreen with ProgressBar

Posted on 2007-09-28
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 24

    Expert Comment

    by:Tomas Helgi Johannsson

    This is just matter of creating a simple form with the desired info/image etc displayed on it
    while loading.
    Simple follow this example :
    Then add the ProgressBar on the SplashForm and update it according to the load of your

       Tomas Helgi
    LVL 18

    Accepted Solution

    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

    Perfect. Thanks!!!

    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
    Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
    Need more eyes on your posted question? Go ahead and follow the quick steps in this video to learn how to Request Attention to your question. *Log into your Experts Exchange account *Find the question you want to Request Attention for *Go to the e…
    In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor ( If you're interested in additional methods for monitoring bandwidt…

    734 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

    Need Help in Real-Time?

    Connect with top rated Experts

    18 Experts available now in Live!

    Get 1:1 Help Now