Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Runtime Component creation

0 views
Skip to first unread message

Bart Engels

unread,
Sep 27, 1999, 3:00:00 AM9/27/99
to
Hi there,

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

TK Boyd

unread,
Sep 27, 1999, 3:00:00 AM9/27/99
to
On Mon, 27 Sep 1999 10:52:24 +0200, "Bart Engels" <ba...@bureau.owg.nl>
wrote:

>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

grust

unread,
Sep 27, 1999, 3:00:00 AM9/27/99
to

Bart Engels wrote <7snb7u$sb7$1...@news1.xs4all.nl>...
>Hi there,
>
Well, to create a TListBox at runtime, this is the least you can do:

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;

0 new messages