I have a descendant of TWinControl
(in fact it is just that for now) and I registered it as a component in the IDE:
type
TGroupPanel = class(TWinControl);
But when I drop other components on it, they attach to the form instead of to my control. In other words, I want my custom control to behave like a TPanel
so that components dropped on it become its children.
If I create the components at runtime and assign them manually to my control, like in the code below, then it works:
TForm1 = class(TForm)
Group: TGroupPanel;
procedure FormCreate(Sender: TObject);
private
Panel: TPanel;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Panel := TPanel.Create(Group);
Panel.Parent := Group;
Panel.Align := alClient;
end;
So, what should I do to get components dropped on a TWinControl
at design time become children of that control?
(What I am trying to do is to make a special control to group other components on, so I can align and position them together. Of course, I can do that with a normal panel, but I want to do this with a lightweight control that does not paint anything, and in TWinControl
I found the solution.)