Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.3k views
in Technique[技术] by (71.8m points)

delphi xe2 - How to create splashscreen in FireMonkey?

I need to create a splashscreen while my FMX program is launching.

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;

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.

How do I create a splashscreen in Delphi XE2 FireMonkey project?

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

1.4m articles

1.4m replys

5 comments

57.0k users

...