August 7th, 2009, 10:34 AM
Problem with adding custom event to a COM (ActiveX) Control
I'm really new in all this so forgive if the some parts of the question are stupid.
I'm having an ActiveX control (say abc) which is instantiated from an html page using its CLSID. It is having some properties as well as events. (Which we catch by simple JScript 'for' and 'event' attributes. )
Now, this class inherits from/implements a lot of interfaces and classes like CComObjectRootEx<CComSingleThreadModel>, CComCoClass, CComControl, IDispatchImpl, IConnectionPointContainerImpl etc. etc. and also the almost standard CProxy_abcEvents class (which in turn inerits from IConnectionPointImpl and the interface which defines the Events in form 'Fire_OnSomethingHappened'). This same class also provides a method called 'CoCreateInstance' which we used to create another com object xyz which provided only properties and no events.
The problem started when I now need to add an event to this other Com object also. So I added the event in the idl file, created another CProxy_xyzEvents class for itself and added the new event in that class, added this proxy to CONNECTION_POINT_MAP and inherited this com class from a number of other interfaces. Also made COM_INTERFACE_ENTRY for IConnectionPointContainer etc.
All this compiles well, but I'm still not getting the event fired when desired.
I noticed that though for the original control 'Advise ()' method is called internally (from mshtml.dll), my new control xyz's Advise method never gets called. Do I need to call that manually? If yes, how do I get the correct IUnknown pointer for that? I'm guessing if I have to call it, I'd need to do that in the CoCreateInstance() of class abc control which creates xyz.
I still don't know if I'm missing inheriting from some other implementations/interfaces.
Thanks a lot for helping !
Tags for this Thread
Click Here to Expand Forum to Full Width
This is a CodeGuru survey question.