Getting events from a COM object RRS feed

  • Question

  • Hello:

    I don´t know if this question belongs or not to this thread, but if you consider that there´s a suitable thread for it, please, let me know.

    About my question: I´m trying to get the events of a COM event source object and a part of this task is implementing the dispinterface handling those events through inheriting the ATL class IDispEventImpl. Later on my code I call to DispEventAdvise in order to connect the outgoing interface of the connectable object (the event source object) with the proper connection point. Everything compiles fine and such a call succeeds, however, the application exits each time it gets an event, so that makes me think that I did something wrong in relation with the event handling mechanism.

    Here there is the sink object implementation:

    static _ATL_FUNC_INFO _funcOnText = {
      CC_STDCALL,             // Calling convention.
      VT_I4,                         // Return type.
      1,                                 // Number of arguments.
      {                                  // Argument types.

    class SrmPseudoDocumentEvents : public IDispEventImpl<1,
           &GUID_NULL, 1, 0>


      SrmPseudoDocumentEvents() {
      virtual ~SrmPseudoDocumentEvents() {
      STDMETHODIMP OnText(BSTR a_recognizedText) {
        KlDebugAlways("Text event !!!");
        return S_OK;

        SINK_ENTRY_INFO(1, __uuidof(SmIa::PseudoDocumentEvents), 0x01, OnText, &_funcOnText)


    And here I call the DispEventAdvise method call:

    SrmPseudoDocumentEvents pseudoDocumentEvents = SrmPseudoDocumentEvents();

      hr = pseudoDocumentEvents.DispEventAdvise(reinterpret_cast<IUnknown*>(m_pIPseudoDocument),
      if (FAILED(hr)) {
        return getHResultInfo(hr,

    Thank you beforehand,

    • Edited by Markkos Wednesday, November 12, 2008 10:33 AM
    Wednesday, November 12, 2008 10:33 AM


All replies