The trick is part of the code in TCustomPanel:
constructor TCustomPanel.Create(AOwner: TComponent);
begin
inherited Create(AOwner);
ControlStyle := [csAcceptsControls {, ... } ];
end;
There are a few more VCL controls that you can go down with csAcceptsControlsin a property ControlStyle.
If you want to do this in your own controls, but do not get down from such a VCL control, then you should do something like this:
- Override Create constructor
- Add
csAcceptsControlsto PropertyControlStyle
Like this sample code:
//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.
- Jeroen