[Lazarus] Manually creating a form

Antonio Fortuny a.fortuny at sitasoftware.lu
Fri Jun 29 11:22:50 CEST 2012


Le 29/06/2012 11:16, Koenraad Lelong a écrit :
> Hi,
>
> I'm trying to manually create a form and in it's OnCreate event 
> populate it with controls. But I'm doing somehing wrong.
> This is my creating sequence :
>
>  form2:=Tform2.Create(nil);
>  form2.ShowModal;
>  Form2.Destroy;
>
> Nothing special I think.
>
> This is a sample of the create-code :
>
> procedure TForm2.FormCreate(Sender: TObject);
>
> var
>   i : integer;
>   upper : integer;
>
> begin
>
> upper:=10;
> for i:=0 to 4 do
>  begin
>    form2.Height:=form2.height+25;
>    edits[i]:=Tedit.Create(self);
>    edits[i].Parent:=form2;
         edits[i].Parent:=Self;
> edits[i].Top:=upper;
>    edits[i].Left:=10;
>    upper:=upper+25;
>  end;
> end;
>
> But when I run the code, I get a segfault at the location where I 
> modify the form's height. If I remove that, I get the form but the 
> edits do not show.
>
> When I modify the code to automatically create the form this works. So 
> I'm clearly missing something.
>
> Any tips, links to documentation ?
>
> Thanks,
>
> Koenraad Lelong.
>
> -- 
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus







More information about the Lazarus mailing list