Search code examples
installationinno-setupsplash-screenpascalscript

Display splash screen in the center of the screen in Inno Setup


I have this code, but it just shows the splash screen in the top left corner of the screen. How to bring the splash screen to the center of the screen help me!

Here is the code:

[Files]
;Hier die Bilddatei für das Splash:
Source: "C:\Users\MINHLUAN\Desktop\program\DatabaseClassic02.bmp"; \
  DestName: "Splash.bmp"; Flags: dontcopy nocompression

[Code]
var Splash  : TSetupForm;

function InitializeSetup(): Boolean;
var
  BitmapImage1 : TBitmapImage;
begin
  Splash := CreateCustomForm;
  Splash.BorderStyle := bsNone;

  BitmapImage1 := TBitmapImage.Create(Splash);
  BitmapImage1.AutoSize := True;
  BitmapImage1.Align := alClient;
  BitmapImage1.Left := 0;
  BitmapImage1.Top := 0;
  BitmapImage1.stretch := True;
  BitmapImage1.Parent := Splash;

  ExtractTemporaryFile('Splash.bmp');
  BitmapImage1.Bitmap.LoadFromFile(ExpandConstant('{tmp}') + '\Splash.bmp');

  Splash.Width := BitmapImage1.Width;
  Splash.Height := BitmapImage1.Height;
  
  Splash.Show;

  BitmapImage1.Refresh;

  Sleep(5000)

  Result := True;
end;

procedure InitializeWizard();
begin
  Splash.Close;
end;

Solution

  • Use TForm.Position:

    Splash.Position := poScreenCenter;