在Delphi设计环境中
可以拖动TBUTTON把它放到FORM上,也可以把它放到PANEL上
放到FORM,PANEL的区别是
在FORM中:tbutton.owner=form,tbutton.parent=form
在PANEL中:tbutton.owner=form,tbutton.parent=panel
问题:对tbutton.parent是何时通过什么方式进行赋值的
可以拖动TBUTTON把它放到FORM上,也可以把它放到PANEL上
放到FORM,PANEL的区别是
在FORM中:tbutton.owner=form,tbutton.parent=form
在PANEL中:tbutton.owner=form,tbutton.parent=panel
问题:对tbutton.parent是何时通过什么方式进行赋值的
procedure TWinControl.Insert(AControl: TControl);
begin
if AControl <> nil then
begin
if AControl is TWinControl then
begin
ListAdd(FWinControls, AControl);
ListAdd(FTabList, AControl);
end else
ListAdd(FControls, AControl);
AControl.FParent := Self; //这里设置了Parent
end;
end;而Owner在构造函数constructor Create(AOwner: TComponent)中就设置了。