How to create splashscreen in FireMonkey?

隐身守侯 提交于 2019-11-29 15:22:57

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.

You can also add a separate TLayout and populate it as you desire. To do so;

  • The splash layout must have the form as its direct owner.
  • The rest of the form should be behind it. And the Form transparency should be enabled.
  • In the FormCreate Event you can add code to do the necessary hiding of the other form controls which can be made easy if you add them to a separate single or set of layouts and hide them instead.
  • You will also require a kind of triggering event for hiding the splash layout and showing the rest of the form as you may desire.

Note: This approach though doesn't show the standard form buttons on the splash screen.

I have done this many a times and it proves to be quiet less complicated than making a separate form and handling it alongside the main form.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!