[英]How to disable child controls at design-time?
I have my own control, derived from TCustomPanel
. 我有自己的控件,源自TCustomPanel
。 It has a child ( TEdit
) on it. 它上面有一个孩子( TEdit
)。
type
TMyControl = class(TCustomPanel)
private
FEditor: TEdit;
public
constructor Create(AOwner: TComponent);
destructor Destroy(); override;
end;
constructor TMyControl.Create(AOwner: TComponent);
begin
FEditor := TEdit.Create(nil);
FEditor.Parent := Self;
end;
destructor TMyControl.Destroy();
begin
FEditor.Free();
end;
When I click on a child control at design-time, it acts as the run-time TEdit
, capturing focus. 当我在设计时单击子控件时,它充当运行时TEdit
,捕获焦点。
How to completely disable child controls at design time? 如何在设计时完全禁用子控件?
I want them to stop answering mouse/keyboard messages. 我希望他们停止回答鼠标/键盘消息。 When I click on them at design-time, I want the parent control to be selected and dragged. 当我在设计时点击它们时,我希望选择并拖动父控件。
Use Self
as the owner in the edit constructor to make your edit sub-component of your panel and to let the panel handle its destruction. 使用Self
作为编辑构造函数中的所有者来创建面板的编辑子组件并让面板处理其销毁。 And call SetSubComponent
function with the IsSubComponent
paremeter set to True for each sub-component to see your panel control as one in the structure pane. 并调用SetSubComponent
函数,并为每个子组件将IsSubComponent
参数设置为True,以将面板控件视为结构窗格中的一个。
constructor TMyControl.Create(AOwner: TComponent);
begin
...
FEditor := TEdit.Create(Self);
FEditor.SetSubComponent(True);
FEditor.Parent := Self;
...
end;
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.