您必须覆盖Controls.TControl.SetParent方法.
TMyChild = class(TControl)
protected
procedure SetParent(AParent: TWinControl); override;
end;
procedure TMyChild.SetParent(AParent: TWinControl);
begin
if (AParent <> nil) then
begin
if not (AParent is TMyParent) then
raise Exception.CreateFmt('Sorry, MyChild needs to be created in MyParent!', [ClassName]);
end;
inherited;
end;
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
181 次 |
| 最近记录: |