Best access method for embedded components
Posted on 1998-10-06
I have a composite component contained within a TPanel. I want to know the best way to expose properties of the embedded controls to users of the component. Events are easy to expose because they are pointers, so I can hook them up in the constructor. However, I want to know if I can directly hook exposed properties to inherited properties of contained components, without going through a mission. Somebody has a neat way, I'm sure.
Consider the simplistic example of the Color property. If a user changes the Color property, the (container) TPanel changes color. I would like it to change one or more of the contained component's color properties (and leave the TPanel's color alone). Since Color is inherited by both components, it would be nice to avoid having to create a placeholder. The complexity increases when considering that a user may change the color at runtime; I need to make a deep copy of the reference (as opposed to a kludge which may set the color once properly in the constructor). It seems silly to me to have to redeclare TColor and then hook into a color change event etc.... for each property that I wish to expose. This functionality is so easily accomplished with events; is there a way to do this for non-event type properties?