开发者

Showing a splash image is blank some seconds

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,

  1. Splash image is loaded and shown a fraction of a second.
  2. Splash image got blank 2-3 seconds.
  3. Splash image is shown again some seconds.
  4. 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
 开发者_StackOverflow中文版 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.ProcessMessages after SplashForm.Show.


Perhaps it's not this obvious, but your code appears to show the splash screen and then immediately close it. What happens if you comment out the line that says SplashForm.Close?


I think I understand it now. My application use Bold and it takes some seconds to load the model. It is during that time the splash is blank. I managed to decrease that time a bit but I don't want to clutter the internals of Bolds SetFromModel with Application.ProcessMessages.

I think it is ok as this. But thanks for your comments. it points me in the right direction.

/Roland

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜