And*_*rew 3 delphi controls design-time
我拥有自己的控制权TCustomPanel.它上面有一个child(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;
Run Code Online (Sandbox Code Playgroud)
当我在设计时单击子控件时,它充当运行时TEdit,捕获焦点.
如何在设计时完全禁用子控件?
我希望他们停止回答鼠标/键盘消息.当我在设计时点击它们时,我希望选择并拖动父控件.
使用Self作为所有者在编辑构造函数以使您的面板在编辑子组件,并让面板处理其破坏.并调用SetSubComponent函数,将IsSubComponent每个子组件的参数设置为True,以将面板控件视为结构窗格中的一个.
constructor TMyControl.Create(AOwner: TComponent);
begin
...
FEditor := TEdit.Create(Self);
FEditor.SetSubComponent(True);
FEditor.Parent := Self;
...
end;
Run Code Online (Sandbox Code Playgroud)