如何在设计时创建将不会存储在表单中的组件? [英] How to create at design time a component that will be not stored in the form?
本文介绍了如何在设计时创建将不会存储在表单中的组件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个自定义组件,在设计时可以创建这样的子组件:
i have a custom component that at design time can create a child component like this :
constructor TALRectangle.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
fShadow := TalShadow.Create;
fShadow.OnChanged := ShadowChanged;
end;
procedure TALRectangle.ShadowChanged(Sender: TObject);
begin
...
if shadow.enabled then begin
fShadowEffect := TshadowEffect.Create(self);
fShadowEffect.Parent := self;
end;
...
end;
问题是我会以dfm / fmx的形式出现:
The problem is that I will have after in the dfm/fmx form :
object ALRectangle1: TALRectangle
shadow.enabled = True
object TShadowEffect
Softness = 0.500000000000000000
Opacity = 1.000000000000000000
ShadowColor = x96000000
end
end
当我动态创建和初始化此对象时,并不想以dfm / fmx形式使用TShadowEffect。
but I don't want to anything regarding TShadowEffect in the dfm/fmx form as i create and init this object on the fly.
怎么办?
推荐答案
有两种处理方法
-
在设计时根本不要创建
TShadowEffect
对象开始的时间:
procedure TALRectangle.ShadowChanged(Sender: TObject);
begin
...
if fShadow.Enabled and not (csDesigning in ComponentState) then begin
fShadowEffect := TShadowEffect.Create(Self);
fShadowEffect.Parent := Self;
end;
...
end;
如果必须创建它,则设置其 已存储
属性设置为false:
if you must create it, then set its Stored
property to false:
procedure TALRectangle.ShadowChanged(Sender: TObject);
begin
...
if fShadow.Enabled then begin
fShadowEffect := TShadowEffect.Create(Self);
fShadowEffect.Parent := Self;
fShadowEffect.SetSubComponent(True);
fShadowEffect.Stored := False;
end;
...
end;
这篇关于如何在设计时创建将不会存储在表单中的组件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文