tcustomcontrol

how to create a TCustomControl that behaves like Tpanel?

会有一股神秘感。 提交于 2019-12-11 07:07:24
问题 how do I create a TCustomControl that will behave like Tpanel? eg MyCustomComponent, that I can drop components in like labels, images etc. 回答1: The trick is this piece of code in TCustomPanel: constructor TCustomPanel.Create(AOwner: TComponent); begin inherited Create(AOwner); ControlStyle := [csAcceptsControls {, ... } ]; //... end; There are many more VCL controls you can descend from that have csAcceptsControls in their ControlStyle property. If you want to do this in your own controls,