Getting data from a connection point (event)
I am trying to implement a connection point / event to get data.
The method is defined in my IDL as follows:
[id(4), helpstring("method InquireAbort")] HRESULT InquireAbort([in]
VARIANT_BOOL *Abort);
The wizard produces the code below with the exception of this line:
avarParams[0] = Abort; avarParams[0].vt = VT_PTR;
the wizard actually produces this code:
avarParams[0] = Abort; avarParams[0].vt = VT_PBOOL
but VT_PBOOL does not seem to be defined anywhere so I changed it to VT_PTR
But I still cannot obtain a the value that is set.
if I call Fire_InquireAbort, abort still stays to false even though the
client application is setting it to true.
VARIANT_BOOL abort=0;
m_gpsObj->Fire_InquireAbort(&abort);
What am I doing wrong?
HRESULT Fire_InquireAbort( VARIANT_BOOL * Abort)
{
HRESULT hr = S_OK;
T * pThis = static_cast<T *>(this);
int cConnections = m_vec.GetSize();
for (int iConnection = 0; iConnection < cConnections; iConnection++)
{
pThis->Lock();
CComPtr<IUnknown> punkConnection = m_vec.GetAt(iConnection);
pThis->Unlock();
IDispatch * pConnection = static_cast<IDispatch *>(punkConnection.p);
if (pConnection)
{
CComVariant avarParams[1];
avarParams[0] = Abort; avarParams[0].vt = VT_PTR;
CComVariant varResult;
DISPPARAMS params = { avarParams, NULL, 1, 0 };
hr = pConnection->Invoke(4, IID_NULL, LOCALE_USER_DEFAULT,
DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
}
}
return hr;
}
};
--
Bruce E. Stemplewski
GarXface OCX and C++ Class Library for the Garmin GPS
www.stempsoft.com