Answered by:
Getting events from a COM object

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.
VT_BSTR
}
};
class SrmPseudoDocumentEvents : public IDispEventImpl<1,
SrmPseudoDocumentEvents,
&__uuidof(SmIa::PseudoDocumentEvents),
&GUID_NULL, 1, 0>
{
public:
SrmPseudoDocumentEvents() {
};
virtual ~SrmPseudoDocumentEvents() {
};
STDMETHODIMP OnText(BSTR a_recognizedText) {
KlDebugAlways("Text event !!!");
return S_OK;
};
BEGIN_SINK_MAP(SrmPseudoDocumentEvents)
SINK_ENTRY_INFO(1, __uuidof(SmIa::PseudoDocumentEvents), 0x01, OnText, &_funcOnText)
END_SINK_MAP()
};
And here I call the DispEventAdvise method call:
SrmPseudoDocumentEvents pseudoDocumentEvents = SrmPseudoDocumentEvents();
hr = pseudoDocumentEvents.DispEventAdvise(reinterpret_cast<IUnknown*>(m_pIPseudoDocument),
&__uuidof(SmIa::PseudoDocumentEvents));
if (FAILED(hr)) {
return getHResultInfo(hr,
reinterpret_cast<IDispatch*>(&pseudoDocumentEvents),
__uuidof(SmIa::PseudoDocumentEvents));
}
Thank you beforehand,
Marcos
- Edited by Markkos Wednesday, November 12, 2008 10:33 AM
Wednesday, November 12, 2008 10:33 AM
Answers
-
Thanks for your post, however this is not the correct forum to get you the answers you need. This forum is for supporting Microsoft Open Protocol Documentation.
Please re-post your question at the following forum and they should be able to assist you:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.win32.programmer.ole&cat=en_US_680971e3-7fb0-4874-bb98-325f8ba6ede0&lang=en&cr=US
Hongwei Sun -MSFT- Marked as answer by Hongwei Sun-MSFTMicrosoft employee, Moderator Wednesday, November 12, 2008 5:04 PM
Wednesday, November 12, 2008 5:03 PMModerator
All replies
-
Thanks for your post, however this is not the correct forum to get you the answers you need. This forum is for supporting Microsoft Open Protocol Documentation.
Please re-post your question at the following forum and they should be able to assist you:
http://www.microsoft.com/communities/newsgroups/en-us/default.aspx?dg=microsoft.public.win32.programmer.ole&cat=en_US_680971e3-7fb0-4874-bb98-325f8ba6ede0&lang=en&cr=US
Hongwei Sun -MSFT- Marked as answer by Hongwei Sun-MSFTMicrosoft employee, Moderator Wednesday, November 12, 2008 5:04 PM
Wednesday, November 12, 2008 5:03 PMModerator -
One correction. This forum is for conversation for Interoperability, not for open protocol documentation. Please re-post your question on the forum listed in the previous reply.
Hongwei Sun -MSFTWednesday, November 12, 2008 6:02 PMModerator