Let the components dropped on my control in the IDE become children of my control
I have a descendant TWinControl
(which is actually the case now) and I registered it as a component in the IDE:
type
TGroupPanel = class(TWinControl);
But when I drop other components onto it, they attach to the form instead of my control. In other words, I want my custom control to behave like TPanel
so that the components dropped on it become its children.
If I create 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 do I need to do to make components dropped to TWinControl
at design time become children of this control?
(I'm trying to make special control for grouping other components, so I can align them and put them together. Of course I can do this with a regular panel, but I want to do it with a lightweight control that doesn't draw anything, and in TWinControl
I found a solution.)
source to share