在我的应用程序中,我在连接到数据库和其他初始化过程中有启动图像。它可以很好地显示启动图像,但它是空白的。 所以,
- 启动图像在几分之一秒内加载并显示。
- 初始图像空白 2-3 秒。
- 几秒钟后再次显示初始图像。
- Splash 已关闭。
有什么聪明的方法可以尽快显示图像并删除空白图像吗?
DPR 文件中的代码:
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;
还有飞溅单元:
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;
问候 罗兰
最佳答案
您的 SplashForm 需要接收 WM_PAINT 消息才能显示自己,除非消息泵正常工作,否则不会发生这种情况。
将 Application.ProcessMessages
放在 SplashForm.Show
之后。
关于performance - 显示初始图像几秒钟是空白的,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4860029/