tobjectpascal
asked on
Runtime created objects
For N:=0 to Form1.ComponentCount-1 do
Begin
ListBox1.Items.Add(Form1.C omponents[ N].Name);
End;
simple enough it lists all the controls in listbox, but, if you create an object for example Button: Tbutton; .... Button:=TButton.Create(... ); Button.Left.... and so on set the parenthandle, and then make it visible, loop through all the components on the form, and the user created component does not show up...
is that a bug or is that what it's supposed to do?
Begin
ListBox1.Items.Add(Form1.C
End;
simple enough it lists all the controls in listbox, but, if you create an object for example Button: Tbutton; .... Button:=TButton.Create(...
is that a bug or is that what it's supposed to do?
ASKER
if it's a new project, and i do Tbutton.Create(Form); it still does not appear on the list..
Var
B: TButton;
begin
B:=TButton.Create(Form1);
B.ParentWindow:=Form1.Hand le;
B.Top:=1;
B.Left:=1;
B.Width:=100;
B.Height:=100;
B.Visible:=True;
B.Caption:='Press Me';
End;
procedure TForm1.Button1Click(Sender : TObject);
Var
N: Integer;
begin
For N:=0 to Form1.ComponentCount-1 do
Begin
ListBox1.Items.Add(Form1.C omponents[ N].Name);
End;
end;
I must be missing something then, B.Owner can not be modified so what do you mean?
Var
B: TButton;
begin
B:=TButton.Create(Form1);
B.ParentWindow:=Form1.Hand
B.Top:=1;
B.Left:=1;
B.Width:=100;
B.Height:=100;
B.Visible:=True;
B.Caption:='Press Me';
End;
procedure TForm1.Button1Click(Sender
Var
N: Integer;
begin
For N:=0 to Form1.ComponentCount-1 do
Begin
ListBox1.Items.Add(Form1.C
End;
end;
I must be missing something then, B.Owner can not be modified so what do you mean?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
It would have been appearing in your list as blank.
Rick.
Rick.
ASKER
ahhhh what an idiot i am lol.... thanks
*lol*
good point, RickJ
:-))
good point, RickJ
:-))
usual the runtime-created component is added to the owners componentlist,
if you use nil as owner, well then ....