Splash Screen in delphi applications.

09Nov11

Splash screen is that ‘short-lived’ form that shows up while opening the most of the applications. It normally contains the product name, credits, version etc. Such splash screen can be added to your delphi applications easily. This is how you can do it.

  1. Create a new project in Delphi.
  2. A new form named form1 will be created by default with the unit file unit1.pas Let us make this as a splash screen.
  3. Give an appropriate name for the form say SplashScreen.
  4. Design the form by including product logo, changing the BorderStyle and Position properties.
  5. Go to Project / Options and remove SplashScreen from Auto-Create forms. Because we will be creating this form on the fly.
  6. Now add another form to the project. Let this form be the one that shows up after the splash screen. (File / New / Form). A new form named form2 with the unit file unit2.pas will be created.
  7. Open the .dpr file, by selecting View Source in Project menu. It will be shown as follows
program Project1;
uses
 Forms,
 Unit1 in 'Unit1.pas' {SplashScreen},
 Unit2 in 'Unit2.pas' {Form2};
{$R *.res}
begin
 Application.Initialize;
 Application.CreateForm(TForm2, Form2);
 Application.Run;
end.
  1. Add the following statements after the begin keyword
SplashScreen := TSplashScreen.Create(nil);
SplashScreen.Show;
Application.Initialize;   //already existing.
SplashScreen.Update;

This will show the form that you have designed with the name SplashScreen

After the Application.CreateForm(TForm2, Form2) add the following statements to hide the splash screen and also to free the object.

SplashScreen.Hide;
SplashScreen.Free;

After these lines the Application.Run; statement comes and the further forms would shown up. In this case the second form (Form2) will show up. If your application is small, and there is no much resources to get initialised then this splash screen will be closed very fast. You can delay it by introducing sleep() after the SplashScreen.Update.

Advertisements


No Responses Yet to “Splash Screen in delphi applications.”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s


%d bloggers like this: