In my application I have a splash image during connection to database and other initialization . It works fine to show the splash image, but there it is blank of a period.
So,
- Splash image is loaded and shown a fraction of a second.
- Splash image got blank 2-3 seconds.
- Splash image is shown again some seconds.
- Splash is closed.
Is there a clever thing to just show the image as quick as possible and remove the blank image ?
The code in the DPR-file:
Application.Initialize;
SplashForm := TSplashForm.Create(Application);
SplashForm.Show;
// Tried Splash.Update here but no difference.
SplashForm.SetPos(15);
// Init code
SplashForm.SetPos(30);
// More Init code
SplashForm.SetPos(100);
SplashForm.Close;
Application.Run;
And the splash unit:
procedure TSplashForm.FormClose(Sender: TObject; var Action: TCloseAction);
begin
Action := caFree;
end;
procedure TSplashForm.FormCreate(Sender: TObject);
begin
pbLoading.Properties.Text := 'Loading ' + TClientConfig.Instance.AppTitle + '...';
end;
procedure TSplashForm.SetPos(aPos: Integer);
begin
pbLoading.Position := aPos;
UpDate;
end;
Regards
Roland
Your SplashForm needs to receive the WM_PAINT message in order to show itself, and that’s not going to happen unless the message-pump is working.
Put
Application.ProcessMessagesafterSplashForm.Show.