[lazarus] Splash screen woes
Mattias Gaertner
nc-gaertnma at netcologne.de
Mon Oct 7 18:20:47 EDT 2002
On 07 Oct 2002 10:47:33 -0500
Tony Maro <tonym at nlisc.com> wrote:
> This is odd.
>
> I'm working on a splash screen for my app (since loading 3 years of
> transactions may take a few seconds)
> and ran into the following:
>
> Here's from my LPR:
>
> var
> MyParam: String;
> begin
> if paramcount > 0 then begin
> MyParam := Paramstr(1);
> end;
> if ((MyParam = '-h') or (MyParam = '-v')) then begin
> writeln('CheckBook Tracker');
> writeln('Written by Anthony Maro');
> writeln('-----------------------');
> writeln('Version 0.9.2');
> end else begin
>
> Application.Initialize;
> FrmSplash := TFrmSplash.Create(Application);
> FrmSplash.Show;
> FrmSplash.Refresh;
> Application.Processmessages;
> Application.CreateForm(TFrmMain, FrmMain);
> Application.CreateForm(TFrmAbout, FrmAbout);
> Application.CreateForm(TFrmSettings, FrmSettings);
> Application.CreateForm(TFrmBalance, FrmBalance);
> Application.CreateForm(TFrmStarting, FrmStarting);
> Application.CreateForm(TFrmNewSchedDep, FrmNewSchedDep);
> Application.CreateForm(TFrmWorking, FrmWorking);
> Application.CreateForm(TFrmEnterDep, FrmEnterDep);
> Application.CreateForm(TFrmEnterWithdrawal, FrmEnterWithdrawal);
> // Application.CreateForm(TFrmSplash, FrmSplash);
> Application.Run;
>
> end;
>
> end.
>
> You can see I'm forcing the FrmSplash to display prior to loading the
> other forms. I then close and free it at the end of the FrmMain.OnShow
> event
The first form added to 'Application' is the Application.MainForm. The LCL expects the MainForm to close only at the end.
See lazarus.pp and splash.pp for an example how to implement a splash screen.
Lazarus does not close the splash screen on Show, because this is not the end of loading. There are still a lot of handles and other things to create. Instead Lazarus closes the splash screen, as soon as the program has started and waits for user input (Application.OnIdle).
> This works just great UNLESS the FrmMain position is set to
> poDesktopCenter. There may be other position settings that might crash
> too, but poDesigned and poDefault work fine.
>
> net result is that as soon as FrmMain is shown, the application crashes
> in TCONTROL__SETVISIBLE line 1624 with access violation.
You didn't send the complete backtrace, but I guess the missing control is Application.MainForm.
Mattias
More information about the Lazarus
mailing list