MakeActiveXClass events

Is there any way to associate methods with activeX control events when
the derived activeX control class is instantiated or after it has been
instantiated? More specifically my problem is that I have a class
that is sub-classed from an activeX control class created with
MakeActiveXClass. I need several instances of this class each with
their own set of event handlers. I can obviously create a new class
for each instance but as far as I can see that means duplicating the
code for each of the sub-classes which is obviously not very
desirable.

Does anyone have any experience of this kind of thing?

Not I, but one idea I have is to use a mix-in class pattern where you have a class for each set of event handlers that you need. Then you can combine them with the activeX class to make each of the derived classes that you need. For example:

class MyActiveXClassFoo(MyActiveXClass, MyEventClassFoo):
  pass

class MyActiveXClassBar(MyActiveXClass, MyEventClassBar):
  pass

···

On 12/21/11 8:01 AM, PeterW wrote:

Is there any way to associate methods with activeX control events when
the derived activeX control class is instantiated or after it has been
instantiated? More specifically my problem is that I have a class
that is sub-classed from an activeX control class created with
MakeActiveXClass. I need several instances of this class each with
their own set of event handlers. I can obviously create a new class
for each instance but as far as I can see that means duplicating the
code for each of the sub-classes which is obviously not very
desirable.

Does anyone have any experience of this kind of thing?

--
Robin Dunn
Software Craftsman