[lazarus] Splash screen woes
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:
> MyParam: String;
> if paramcount > 0 then begin
> MyParam := Paramstr(1);
> if ((MyParam = '-h') or (MyParam = '-v')) then begin
> writeln('CheckBook Tracker');
> writeln('Written by Anthony Maro');
> writeln('Version 0.9.2');
> end else begin
> FrmSplash := TFrmSplash.Create(Application);
> 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);
> 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
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.
More information about the Lazarus