gpt4 book ai didi

delphi - 如何在设计时禁用子控件?

转载 作者:行者123 更新时间:2023-12-03 15:48:39 25 4
gpt4 key购买 nike

我有自己的控件,源自TCustomPanel。它上面有一个子项 (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;

当我在设计时单击子控件时,它充当运行时TEdit,捕获焦点。

如何在设计时完全禁用子控件?

我希望他们停止回答鼠标/键盘消息。当我在设计时单击它们时,我希望选择并拖动父控件。

最佳答案

在编辑构造函数中使用Self作为所有者来创建面板的编辑子组件并让面板处理其销毁。并调用SetSubComponent函数,将每个子组件的 IsSubComponent 参数设置为 True,以便将面板控件视为结构 Pane 中的一个。

constructor TMyControl.Create(AOwner: TComponent);
begin
...
FEditor := TEdit.Create(Self);
FEditor.SetSubComponent(True);
FEditor.Parent := Self;
...
end;

关于delphi - 如何在设计时禁用子控件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11209523/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com