Splash screen

From ISXKB

Revision as of 17:53, 18 December 2007 by Markus (Talk | contribs)
(diff) ←Older revision | Current revision (diff) | Newer revision→ (diff)
Jump to: navigation, search

Contents

Introduction

A splash screen is a picture or logo displayed after an application has been started but before its user interface comes up.

Although considered beeing annoying it can make sence to display a splash screen in an installer if it takes a long time to show its interface because of a lot of initialization stuff.

The [Files] section

The first thing that's needed is the splash bitmap itself. It can be included in a [Files] section.

[Files]
Source: Splash.bmp; DestDir: {tmp}; Flags: dontcopy

The code

Three functions (Pascal: procedures) form the logical structure. OpenSplash reads the bitmap and creates the splash form. ShowSplash displays it and CloseSplash closes it again.

[Code]
var
  PreviousBackupName  : String;
  SplashFileName      : String;
  SplashForm          : TForm;
  SplashImage         : TBitmapImage;

procedure OpenSplash;
begin
  SplashFileName := ExpandConstant ('{tmp}\Splash.bmp');
  ExtractTemporaryFile ('Splash.bmp');
  SplashForm := TForm.create(nil);
  with SplashForm do
    begin
      BorderStyle := bsNone;
       Position := poScreenCenter;
      // Adjust the height and width of the SplashForm to the size of your splash image
      ClientWidth := 300;
      ClientHeight := 103;
    end;
  SplashImage := TBitmapImage.Create(SplashForm);
  with SplashImage do
    begin
      Bitmap.LoadFromFile(SplashFileName);
      Stretch := true;
      Align := alClient;
      Parent := SplashForm;
    end;
end;

procedure ShowSplash;
begin
  with SplashForm do
   begin
     Show;
     Repaint;
   end;
   BringToFrontAndRestore;
end;

procedure CloseSplash;
begin
  with SplashForm do
   begin
     Close;
     Free;
   end;
   BringToFrontAndRestore;
end;

The bitmap can then be opened and shown in InitializeSetup ().

function InitializeSetup : Boolean;
begin
  OpenSplash;
  ShowSplash;
  // Your initialization stuff goes here...
  Result := TRUE;
end;

As soon as the wizard is there the splash can be closed and discarded (in InitializeWizard).

procedure InitializeWizard;
begin
  // ...or here (initialization stuff).
  CloseSplash;
end;

See also

External links

Personal tools
Ads: