I’ve been searching the whole internet for an answer but I cant find one.
What I want to do is to create a component that I, in design time, can add components to, move them around, right click on them to pop up a menu, change their properties, etc etc.
Like, for instance, I drop my component “A” (which is based on TImage32 from the Graphics32 library), and then I want to be able to drop a component “B” (which is based on TBitmap32) in to A, but since B is not inherited from a standard VCL like TPanel I dont know how to make a design time component.
What you are searching for is the ability to create a parent/child relationship. The parent acts as a container and the child is contained within the bounds of the container. A
TPanelis a classic example of a container. Any visual component can be a child.In terms of ancestry the parent must be derived from
TWinControland the child must be derived fromTControl. In practice you seldom derive from these classes directly, rather from one of their descendents. The other factor, if I recall correctly, is that the parent control must includecsAcceptsControlsin itsControlStyle.Now,
TImage32does indeed derive fromTWinControland so it can act as a container. However, I am not sure whether or notcsAcceptsControlsis included in theControlStyleforTImage32.I’m really not familiar withTImage32and don’t know whether or not it can act as a parent. I have a suspicion that it is not designed to act as a container. If that is the case then you can addcsAcceptsControlsto theControlStylein the constructor of your derived class and have the control act as a parent.I suspect that if
TImage32does not includecsAcceptsControlsthen this is by design and the image control is not expected to act as a parent.Apparently
TImage32, unlike the VCLTImage, is indeed capable of acting as a parent to other controls.As for the other control in your question,
TBitmap32is not derived fromTControland cannot be a child control.