XBa*_*000 1 delphi tpanel tcustomcontrol custom-component
如何创建一个像Tpanel一样的TCustomControl?例如MyCustomComponent,我可以删除类似标签,图像等组件.
诀窍是TCustomPanel中的这段代码:
constructor TCustomPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csAcceptsControls {, ... } ];
//...
end;
Run Code Online (Sandbox Code Playgroud)
您可以csAcceptsControls从其ControlStyle属性中获得更多VCL控件.
如果你想在自己的控件中执行此操作,但不要从这样的VCL控件中执行此操作,那么您应该执行以下操作:
csAcceptsControls到ControlStyle物业像这个示例代码:
//MMWIN:MEMBERSCOPY
unit _MM_Copy_Buffer_;
interface
type
TMyCustomControl = class(TSomeControl)
public
constructor Create(AOwner: TComponent); override;
end;
implementation
{ TMyCustomControl }
constructor TMyCustomControl.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := ControlStyle + [csAcceptsControls {, ...} ];
//...
end;
end.
Run Code Online (Sandbox Code Playgroud)
--jeroen
| 归档时间: |
|
| 查看次数: |
1470 次 |
| 最近记录: |