COM & EventSink and IDispatch
-
I have used the class wizard to generate a wrapper class from the type library of an in process server. I can access the methods and properties by creating a dispatch like this one for both. if(((*(COleDispatchDriver*)(&m_IMCSClientEvents))).m_lpDispatch==NULL){ //UCS_MCSSERVER.EXE if (!(m_IMCSClientEvents.CreateDispatch("MCSObject.MCSObject.1", &oe))) { But how do I capture the events. Do you create a dispatch for events? If so how do you capture them? I'm confused. I suspect the answer is use the EVENTSINK_MAP. But that would require an IDC value. Since I am late binding I do not have an IDC value I am not sure how to use the EVENTSINK_MAP. Thanks in advance.
-
I have used the class wizard to generate a wrapper class from the type library of an in process server. I can access the methods and properties by creating a dispatch like this one for both. if(((*(COleDispatchDriver*)(&m_IMCSClientEvents))).m_lpDispatch==NULL){ //UCS_MCSSERVER.EXE if (!(m_IMCSClientEvents.CreateDispatch("MCSObject.MCSObject.1", &oe))) { But how do I capture the events. Do you create a dispatch for events? If so how do you capture them? I'm confused. I suspect the answer is use the EVENTSINK_MAP. But that would require an IDC value. Since I am late binding I do not have an IDC value I am not sure how to use the EVENTSINK_MAP. Thanks in advance.
Hi! As you've already mentioned you can't use the event map in the late binding. You have to implement the event sink and then use one of the functions below to create a connection between an object's connection point and a client's sink: CComPtr::Advise(...) - using smart pointers AtlAdvise(...) - using ATL IConnectionPoint::Advise(...) - generic interface method And of course you have to Unadvise when you are done with the object. Regards, Alex Gorev, Dundas Software. ================== The original message was:
I have used the class wizard to generate a wrapper class from the type library
of an in process server.I can access the methods and properties by creating a dispatch like this one for both.
if(((*(COleDispatchDriver*)(&m_IMCSClientEvents))).m_lpDispatch==NULL){ //UCS_MCSSERVER.EXE
if (!(m_IMCSClientEvents.CreateDispatch("MCSObject.MCSObject.1", &oe))) {But how do I capture the events. Do you create a dispatch for events? If so how do you capture them? I'm confused.
I suspect the answer is use the EVENTSINK_MAP. But that would require an IDC value. Since I am late binding
I do not have an IDC value I am not sure how to use the EVENTSINK_MAP.Thanks in advance.
-
I have used the class wizard to generate a wrapper class from the type library of an in process server. I can access the methods and properties by creating a dispatch like this one for both. if(((*(COleDispatchDriver*)(&m_IMCSClientEvents))).m_lpDispatch==NULL){ //UCS_MCSSERVER.EXE if (!(m_IMCSClientEvents.CreateDispatch("MCSObject.MCSObject.1", &oe))) { But how do I capture the events. Do you create a dispatch for events? If so how do you capture them? I'm confused. I suspect the answer is use the EVENTSINK_MAP. But that would require an IDC value. Since I am late binding I do not have an IDC value I am not sure how to use the EVENTSINK_MAP. Thanks in advance.
It's me again... You also can have a look on the very nice article in MSDN: "HOWTO: Create a Sink Interface in MFC-Based COM Client" Article ID: Q181845 Alex Gorev, Dundas Software. ================== The original message was:
I have used the class wizard to generate a wrapper class from the type library
of an in process server.I can access the methods and properties by creating a dispatch like this one for both.
if(((*(COleDispatchDriver*)(&m_IMCSClientEvents))).m_lpDispatch==NULL){ //UCS_MCSSERVER.EXE
if (!(m_IMCSClientEvents.CreateDispatch("MCSObject.MCSObject.1", &oe))) {But how do I capture the events. Do you create a dispatch for events? If so how do you capture them? I'm confused.
I suspect the answer is use the EVENTSINK_MAP. But that would require an IDC value. Since I am late binding
I do not have an IDC value I am not sure how to use the EVENTSINK_MAP.Thanks in advance.
-
Hi! As you've already mentioned you can't use the event map in the late binding. You have to implement the event sink and then use one of the functions below to create a connection between an object's connection point and a client's sink: CComPtr::Advise(...) - using smart pointers AtlAdvise(...) - using ATL IConnectionPoint::Advise(...) - generic interface method And of course you have to Unadvise when you are done with the object. Regards, Alex Gorev, Dundas Software. ================== The original message was:
I have used the class wizard to generate a wrapper class from the type library
of an in process server.I can access the methods and properties by creating a dispatch like this one for both.
if(((*(COleDispatchDriver*)(&m_IMCSClientEvents))).m_lpDispatch==NULL){ //UCS_MCSSERVER.EXE
if (!(m_IMCSClientEvents.CreateDispatch("MCSObject.MCSObject.1", &oe))) {But how do I capture the events. Do you create a dispatch for events? If so how do you capture them? I'm confused.
I suspect the answer is use the EVENTSINK_MAP. But that would require an IDC value. Since I am late binding
I do not have an IDC value I am not sure how to use the EVENTSINK_MAP.Thanks in advance.
Thanks Alex. I appreciate it. ================== The original message was: Hi!
As you've already mentioned you can't use the event map in the late binding. You have to implement the event sink and then use one of the functions below to create a connection between an object's connection point and a client's sink:
CComPtr::Advise(...) - using smart pointers
AtlAdvise(...) - using ATL
IConnectionPoint::Advise(...) - generic interface method
And of course you have to Unadvise when you are done with the object.
Regards,
Alex Gorev,
Dundas Software.==================
The original message was:I have used the class wizard to generate a wrapper class from the type library
of an in process server.I can access the methods and properties by creating a dispatch like this one for both.
if(((*(COleDispatchDriver*)(&m_IMCSClientEvents))).m_lpDispatch==NULL){ //UCS_MCSSERVER.EXE
if (!(m_IMCSClientEvents.CreateDispatch("MCSObject.MCSObject.1", &oe))) {But how do I capture the events. Do you create a dispatch for events? If so how do you capture them? I'm confused.
I suspect the answer is use the EVENTSINK_MAP. But that would require an IDC value. Since I am late binding
I do not have an IDC value I am not sure how to use the EVENTSINK_MAP.Thanks in advance.