Y
yxz123
Unregistered / Unconfirmed
GUEST, unregistred user!
写一个控件,动态创建的一个Button
constructor TASGrid.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FBtnTest:=TButton.Create(nil);
FBtnTest.parent:=TWincontrol(AOwner);
FBtnTest.Caption:='┅';
FBtnTest.OnClick:=BtnClick;
FBtnTest.BringToFront;//没有这句就不会出错
end;
destructor TASGrid.Destroy;
begin
if Assigned(FBtnTest) then
FBtnTest.Free;//报错
if Assigned(FcbTest) then
FcbTest.Free;//报错
inherited Destroy;
end;
谁能告诉我原因,如何解决?
constructor TASGrid.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
FBtnTest:=TButton.Create(nil);
FBtnTest.parent:=TWincontrol(AOwner);
FBtnTest.Caption:='┅';
FBtnTest.OnClick:=BtnClick;
FBtnTest.BringToFront;//没有这句就不会出错
end;
destructor TASGrid.Destroy;
begin
if Assigned(FBtnTest) then
FBtnTest.Free;//报错
if Assigned(FcbTest) then
FcbTest.Free;//报错
inherited Destroy;
end;
谁能告诉我原因,如何解决?