Problem:
Event notifications (From COM object - Server) are not received as listed in the Sink (class) implementation.
One event notification is received (Event_one), however, others are not received accordingly
If order is changed - in IDispatch::Invoke, that is:
- if
Event_one
is swapped toEvent_two
thenEvent_two
notification received butEvent_one
and others neglected accordingly
- if
Question:
- Better way to implement, IDispatch::Invoke or QI?
- Using the wrong logic or approach?
Note:
- No MFC
- No ATL
- Pure C++
- using message loop: GetMessage()
- STA model ( Coinitialize() )
- Call to IDispatch::Advise successful (HRESULT from call S_OK)
- After above, COM object method calls as normal (with interface pointer)
- Single call to Advise
- Type library generated from MIDL compiler
For instance (example):
Illustration of IDispatch::Invoke - taken from Sink Class:
HRESULT STDMETHODCALLTYPE Invoke(
{
//omitted parameters
// The riid parameter is always supposed to be IID_NULL
if (riid != IID_NULL)
return DISP_E_UNKNOWNINTERFACE;
if (pDispParams) //DISPID dispIdMember
{
switch (dispIdMember) {
case 1:
return Event_one();
case 2:
return Event_two();
case 3:
return Event_three();
default:
return E_NOTIMPL;
}
}
return E_NOTIMPL;
}
Illustration of QueryInterface:
STDMETHOD (QueryInterface)(
//omitted parameters
{
if (iid == IID_IUnknown || iid == __uuidof(IEvents))
{
*ppvObject = (IEvents *)this;
} else {
*ppvObject = NULL;
return E_NOINTERFACE;
}
m_dwRefCount++;
return S_OK;
};