Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. COM & EventSink and IDispatch

COM & EventSink and IDispatch

Scheduled Pinned Locked Moved C / C++ / MFC
questionwpfwcfcomsysadmin
4 Posts 3 Posters 9 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • U Offline
    U Offline
    User 3512
    wrote on last edited by
    #1

    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.

    A 2 Replies Last reply
    0
    • U User 3512

      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.

      A Offline
      A Offline
      Alex Gorev
      wrote on last edited by
      #2

      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.

      L 1 Reply Last reply
      0
      • U User 3512

        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.

        A Offline
        A Offline
        Alex Gorev
        wrote on last edited by
        #3

        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.

        1 Reply Last reply
        0
        • A Alex Gorev

          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.

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #4

          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.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups