Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2002-10

Splash screen woes

5 messages · 3 people ·

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

Andrew Johnson
The first form added to 'Application' is the Application.MainForm.

It shouldn't be. In Delphi the Main form is the first Form created by calling to Application.CreateForm, not Form.Create(Application). In Delphi If I were to do what he has done it would work fine because the Splash was not created using Createform, therefore it isn't the MainForm.

Andrew

_________________________________________________________________ MSN Photos is the easiest way to share and print your photos: http://photos.msn.com/support/worldwide.aspx

Reply by email

Mattias Gaertner
to Andrew Johnson
Show quoted text 9 lines
On Tue, 8 Oct 2002 00:29:26 +0200 "Mattias Gaertner" wrote : >The first form added to 'Application' is the Application.MainForm. It shouldn't be. In Delphi the Main form is the first Form created by calling to Application.CreateForm, not Form.Create(Application). In Delphi If I were to do what he has done it would work fine because the Splash was not created using Createform, therefore it isn't the MainForm.

You are right. The LCL does it also.
The error is something else.
Tony, can you plz send me the complete backtrace or an example?

Mattias

Reply by email

Mattias Gaertner
to Tony Maro: This is odd. I'm working on a splash screen for my app (since loading 3 years of…
This is odd. I'm working on a splash screen for my app (since loading 3 years of transactions may take a few seconds)
Show quoted text 41 lines
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).

Show quoted text 6 lines
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

Reply by email

Tony Maro
to Andrew Johnson: On Tue, 8 Oct 2002 00:29:26 +0200 It shouldn't be. In Delphi the Main form is the first…
Mattias Gaertner wrote
You are right. The LCL does it also. The error is something else. Tony, can you plz send me the complete backtrace or an example?

I couldn't reproduce it in a fresh application so I started digging.

What happens is the form receives a RESIZE message before being shown, but only if it's trying to position the form according to the screen size. Other position methods don't seem to trigger this.

Since I create components in the onshow and then rearrange them in the onresize events it would crap out attempting to move a control that didn't exist yet because OnShow hadn't been called.

-Tony

Reply by email

Tony Maro

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

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.

Reply by email