[Lazarus] TForm.OnCreate and Application.MainForm.Caption

Michael Fuchs freepascal at ypa-software.de
Mon Nov 14 10:57:50 CET 2011


Am 14.11.2011 10:51, schrieb John Landmesser:
> procedure TForm1.FormCreate(Sender: TObject);
> begin
>    // next line produces error
>    Application.MainForm.Caption:= Application.Title;
>    // next line does NOT produce an error
>    Form1.Caption:= Application.Title;
> end;

In FormCreate, the Form1 is not assigned to Application.MainForm. This 
is done after the complete creation process.

> //BUT(!!),you get no error with the OnShow event
>
> procedure TForm1.FormOnShow(Sender: TObject);
> begin
>    // next line does NOT produces  error
>    Application.MainForm.Caption:= Application.Title;
> end;

- the creation process is done
- then Form1 is assigned to Application.MainForm
- then Form1.Show is called

Please take a look into TApplication.CreateForm for further informations.

hth
Michael




More information about the Lazarus mailing list