Board index » cppbuilder » can't derive vcl-classes from two base-classes

can't derive vcl-classes from two base-classes

Hi,

I try to make several components e.g. TDynaEdit, TDynaLabel ...

They should all have the same methods e.g MouseMove(), MouseUp(),
MouseDown, SetRaster

and one property EditMode.

I derived TDynaControl from TCustomControl and implemented the methods
and the property.

Then I tried to derive the new classes from TDynaControl and from e.g. TEdit

but I got an error, that it is not possible to derive vcl-classes from
more than one class.

I need a BaseClass which implements the methods above because the
components will be stored in a list.

How can I make my components work. Must I implement all classes manually
derived from TDynaControl,

or is there a workaround?

Thanx Heiko Mller

 

Re:can't derive vcl-classes from two base-classes


Quote
"Heiko Mller" <heiko....@gmx.de> wrote in message

news:3E7DF8E3.1070805@gmx.de...

Quote
> Then I tried to derive the new classes from TDynaControl
> and from e.g. TEdit

What you ask for cannot be done, sorry.  The VCL does not support multiple
inheritance, except under BCB6 but only with abstract (pure virtual)
interfaces.

Quote
> I need a BaseClass which implements the methods above
> because the components will be stored in a list.

Then you'll just have to forego using the native components altogether,
derive from your base class only, and then implement all of the other
desired functionality manually for each descendant component instead of
inherited it from the native VCL.

Or, at the very least, since your base class is derived from TCustomControl,
then have each descendant component instantiate the desired control
internally in its constructor, setting the Owner and Parent of the control
to be the component instantiating it, and then expose your own properties
that use aggregation to access the control internally, mimicing the native
behavior indirectly.

Quote
> How can I make my components work.

You can't.  Not in the way you're asking for, that is.

Quote
> Must I implement all classes manually derived from TDynaControl,

Yes.

Gambit

Other Threads