【发布时间】:2020-07-16 11:09:18
【问题描述】:
如果一个函数在设计时执行,并创建一个拥有 nil 的 TComponent / TControl 后代,System.Classes 中的以下代码将不会调用 InsertComponent:
constructor TComponent.Create(AOwner: TComponent);
begin
FComponentStyle := [csInheritable];
if AOwner <> nil then AOwner.InsertComponent(Self);
end;
因此,我们的新对象不会继承 ComponentState。 依赖于该组件的 csDesigning 标志的条件会发生什么情况?
if csDesigning in ComponentState
【问题讨论】:
-
问问自己在运行时创建的组件是否在设计时创建过