Search code examples
delphiformslazarusfreepascalfpc

Problem with Splash Screen in Lazarus app


I am porting a Delphi application to FPC/Lazarus and this application shows info in splash screen. When unit has initialization section then this initialization section calls something like:

Splash.Info(unit_name)

This works in Delphi, but when I compiled this using FPC/Lazarus then I got exception when I create form with splash screen:

Failed to create win32 control, error 1407 : Cannot find window class

I found, that forms can be created after Application.Initialize; was called, so my workaround is to create splash form when ScreenInfo.Initialized=true. It works, but does not show all info. Is there any way to show splash form from unit initialization section, before Application.Initialize;?


Solution

  • In SplashScreen initialization code that is called for every string I want to show on this splash I finished with:

    ...
    {$IFDEF FPC}
    if not ScreenInfo.Initialized then
        exit;
    {$ENDIF}
    if not splash_inititialized then begin
      SplashScreen := TSplashScreen.Create(Application);
      splash_inititialized := true;
      ...