I believe all you have to do now is set the parent property. Image_New.Parent := Form1;
AButton.Parent := Form1; If you were putting the button on a panel, for example, you would set the panel as the parent. The parent is where your newly created component will live. Hope this helps!! Robert On Thu, Oct 29, 2009 at 11:03 PM, totallyfreeenergy < totallyfreeene...@yahoo.com> wrote: > > > I was wondering how to create VCL components dynamically. For example > procedure TForm1.Image1DblClick(Sender: TObject); > var > Image_New : TImage; > abutton : TButton; > begin > // FSpell.Image_s1.Picture := FSpell.Image1.Picture; > Image_New := TImage.Create(Form1); > Image_New.Left := 8; > Image_New.Top := 222; > Image_New.Visible := true; > Image_New.Width := 60; > Image_New.Height := 60; > // Image_New.Create(Form1); > Image_New.Picture := Form1.Image1.Picture; > abutton := TButton.Create(Form1); > abutton.Left := 8; > abutton.Top := 250; > abutton.Caption := 'My New Button'; > abutton.Width := 120; > abutton.Height := 40; > end; > This code compiled ok. It had no problems creating Image_New. However the > Image_New and abutton are not there on the form. Obviously it is not created > although it gave no indication and did not crash while executing this code. > > Regards > TFE > http://totallyfreeenergy.zxq.net > > >