Problem with screen saver in Lazarus application

I am migrating a Delphi application to FPC / Lazarus, and this application displays information in a splash screen. When a block has an initialization section, this initialization section calls something like:

Splash.Info(unit_name)

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

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

I found that forms can be created after the call Application.Initialize;, so my workaround is to create a splash form when ScreenInfo.Initialized=true. It works, but does not show all the information. Is there a way to show the shape of the burst from the unit initialization section, before Application.Initialize;?

+3
source share
2 answers

In the SplashScreen initialization code that gets called for every line that I want to show on this splash, I ended up with:

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

Obviously, the FCL / Lazarus VCL implementation is quite different from the Delphi VCL in order to prevent form initialization before the application object has been initialized.

So, the best you can do to get it working in both Delphi and FPC / Lazarus is

  • Complete the initialization until you are sure that both Delphi VCL and FPC / Lazarus VCL are ready for it.
  • Duplicate your code with conditional definitions to create optimal implementations for Delphi VCL and FPC / Lazarus VCL

- Jeroen

+1
source

Source: https://habr.com/ru/post/1727349/


All Articles