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. COM
  4. Implementing sink interface in raw C++?

Implementing sink interface in raw C++?

Scheduled Pinned Locked Moved COM
c++helptutorialquestion
2 Posts 2 Posters 0 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.
  • H Offline
    H Offline
    Henrik Husted
    wrote on last edited by
    #1

    Hi guys. I have an ATL module with an outgoing dispinterface. I have no problem implementing an sink interface using MFC or ATL. But now I'm working on a strait C++ project, no MFC and no ATL, where I need to create an sink interface. Could someone give me some hints on how to implement this? All the information I have been able to find assumes that MFC or ATL is beeing used. TIA .Henrik

    A 1 Reply Last reply
    0
    • H Henrik Husted

      Hi guys. I have an ATL module with an outgoing dispinterface. I have no problem implementing an sink interface using MFC or ATL. But now I'm working on a strait C++ project, no MFC and no ATL, where I need to create an sink interface. Could someone give me some hints on how to implement this? All the information I have been able to find assumes that MFC or ATL is beeing used. TIA .Henrik

      A Offline
      A Offline
      Aaron Schaefer
      wrote on last edited by
      #2

      Since sink interfaces are dispinterfaces, you will have to implement IDispatch on your object. This also implies you'll have to implement IUnknown, since IDispatch is derived from it. Your version of the Invoke method will basically switch on the dispid of the event, unpack the event parameters from the DISPPARMS struct, and delegate to whatever method you want to be invoked when the event is fired. You will also need code for advising and unadvising the connection point. So for IUknown, you need an implementation of QueryInterface, AddRef and Release. For your implementation of IDispatch for the event interface, you can proably take some shortcuts and just implement Invoke, and return E_NOTIMPL from the remaining methods, since the Connection Point would only make use of this method to fire events. Make sure your object is publicly derived from IDispatch. Your implementation for QueryInterface can then just use a static cast of the this pointer to implement QueryInterface. Look at the ATL code that does this for normal objects for an example. Good Luck!

      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