Is there anybody who knows how to create a component at Runtime. It has to
be an editbox and I don't know how much the users want them. How do I
create and destroy those thingles???
Bart
>Hi there,
>
>Is there anybody who knows how to create a component at Runtime....
A set of 'hands on' Delphi tutorials is at...
http://ourworld.compuserve.com/homepages/TK_Boyd/Tut.htm
one takes a beginner through a first programming session, and there
are more advanced tutorials....
and I think one has what you want.
--
http://www.arunet.co.uk/tkboyd/offers.htm
Freeware, shareware for IBM type pcs. Ideas for parents, teachers
procedure TForm1.FormCreate(Sender: TObject);
var EditBox : TEdit; { Declare this in the private section }
begin
EditBox := TEdit.Create(Self);
{ Enter Self as Owner. Owner is the component that owns the new component,
which is Form1 in this case. When the form is destroyed, all the components
it owns are destroyed too. So if you want to destroy EditBox yourself, enter
NIL as parameter :-) }
EditBox.Parent := Self; { Always assign this or you won't see the
component }
EditBox.SetBounds(10,10,100,20);
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
{ If EditBox isn't owned by anything, destroy it yourself. }
EditBox.Free;
end;
Creating event handlers is easy:
{ interface }
TForm1 = class(tform)
private
procedure EditBoxClick(Sender : TObject);
...
{implementation}
procedure TForm1.EditBoxClick(Sender : TObject);
begin
beep;
end;
Write in OnCreate: EditBox.OnClick := EditBoxClick;