|
-
October 31st, 2007, 10:08 AM
#1
Return value of an ATL event
Hi, I have a problem getting a return value from an ATL event.
I my definition of the connection point interface I have this method:
Code:
[id(1), helpstring("method PageFormatted")] HRESULT PageFormatted([in] long pageNumber, [out, retval] BOOL* bRet);
The "interesting part" of the wizard-generated Fire_PageFormatted method is this:
Code:
CComVariant avarParams[1];
avarParams[0] = pageNumber;
avarParams[0].vt = VT_I4;
CComVariant varResult;
if(bRet)
{
varResult.byref = bRet;
varResult.vt = VT_BOOL|VT_BYREF;
}
DISPPARAMS params = { avarParams, NULL, 1, 0 };
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
In the object which handles this event I have defined this handler:
Code:
BOOL __stdcall OnPageFormatted( long pageNumber );
And its _ATL_FUNC_INFO:
Code:
_ATL_FUNC_INFO OnPageFormattedInfo = {CC_STDCALL, VT_BOOL, 1, {VT_I4}};
I fire the event this way:
Code:
BOOL bRet = TRUE;
Fire_PageFormatted( (long) pgNum, &bRet );
But no matter what I return from the handler, the value of bRet is not updated.
Any thoughts what might be wrong?
-
October 31st, 2007, 11:56 PM
#2
Re: Return value of an ATL event
Code:
CComVariant varResult;
///if(bRet)
///{
///varResult.byref = bRet;
///varResult.vt = VT_BOOL|VT_BYREF;
///}
DISPPARAMS params = { avarParams, NULL, 1, 0 };
hr = pConnection->Invoke(1, IID_NULL, LOCALE_USER_DEFAULT, DISPATCH_METHOD, ¶ms, &varResult, NULL, NULL);
if (SUCCEEDED(hr) && SUCCEEDED(hr = varResult.ChangeType(VT_BOOL))) {
*bRet = varResult.boolVal;
}
With best wishes,
Vita
-----------------------
Russian Software Development Network -- http://www.rsdn.ru
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|