如何在FireMonkey中创建启动画面? [英] How to create splashscreen in FireMonkey?
问题描述
我需要在启动FMX程序时创建启动画面。
I need to create a splashscreen while my FMX program is launching.
VCL中的以下代码不再起作用:
The following code from VCL does not works anymore:
SplashScreen := TSplashScreen.Create(Application);
SplashScreen.Show;
Application.Initialize;
SplashScreen.Update; //No such function in FMX
Application.Run;
问题是直到 Application.Run才创建/重新绘制FMX表单。
被执行,因为他们使用一些FMX魔术来重新绘制。不能使用VCL启动画面,因为我需要OSX支持。
Problem is that in FMX forms are not created/repainted until Application.Run
executed, as they use some FMX magic to repaint. Using VCL splashscreen is not an option since I need OSX support.
如何在Delphi XE2 FireMonkey项目中创建启动画面?
How do I create a splashscreen in Delphi XE2 FireMonkey project?
推荐答案
这有效-区别在于 Application
不是由 Owner
初始窗口,并在创建和显示初始窗口之前调用 Application.Initialize
,但要等到之后才创建主窗体
This works - the difference being that the Application
isn't made the Owner
of the splash window, and that Application.Initialize
is called before the splash window is created and displayed, but the main form isn't created until after the splash window is showing.
program Project2;
uses
FMX.Forms,
System.SysUtils,
Unit1 in 'Unit1.pas' {MainForm},
Unit2 in 'Unit2.pas' {SplashForm};
{$R *.res}
begin
Application.Initialize;
SplashForm := TSplashForm.Create(nil);
SplashForm.Show;
Sleep(1000); // Whatever to control display time of splash screen
Application.CreateForm(TMainForm, MainForm);
SplashForm.Close;
SplashForm.Free;
Application.Run;
end.
这篇关于如何在FireMonkey中创建启动画面?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!