I have written a custom control, that has several sub panels. I want these sub panels to accept any additional controls dropped on them at design time.
Unfortunately any control that gets dropped at design time ends up on my custom control, not on the panels. This shows in particular if I try to drop a label: The label's blue dots are shown, but it's caption isn't and if I deselect the label, it is no longer visible at all.
simplified code (only one sub panel):
type
TMyContainer = class(TPanel)
p_SubPanel: TPanel;
public
constructor Create(_Owner: TComponent); override;
end;
constructor TMyContainer.Create(_Owner: TComponent);
begin
inherited;
p_SubPanel := TPanel.Create(Self);
p_SubPanel.Parent := Self;
p_SubPanel.Align := alClient;
end;
What am I doing wrong here?
(Just in case it matters: I am using Delphi 2007.)
[edit]
I have now solved it differently. The component no longer contains panels but refers to external panels. This makes it actually much more flexible, but on the downside it is no longer as intuitive to use.
I would still like to know how to accomplish what I described originally. Isn't there an open source component somewhere that does this, so I can study the source code?