E
Eric
I'm trying to convert a Delphi sample I saw into C++, and so far I'm
not having any luck. Can anyone tell me what is wrong with this code,
or show me a better example of how to set the
"CommandBarButton.Picture" property from an Outlook 2002 Add-in?
Note - I've removed error checking and tried to compress code snippet
as much as possible.
// Some variables
// NOTE - "disp" is an IDispatch interface of a CommandBarButton
DISPPARAMS dp={NULL,NULL,0,0};
IPictureDisp *pd;
PICTDESC pdesc;
VARIANT p1;
// Create a IPictureDisp from a TBitmap (bmp, initialized earlier)
memset(&pdesc,0,sizeof(pdesc));
pdesc.cbSizeofstruct = sizeof(pdesc);
pdesc.picType = PICTYPE_BITMAP;
pdesc.bmp.hbitmap = bmp->Handle;
pdesc.bmp.hpal = bmp->Palette;
OleCreatePictureIndirect(&pdesc,IID_IPictureDisp,FALSE,(void**)&pd);
// Get the Dispatch ID for the "Picture" property
// dispID = 1610940430, which should be correct (from MSDN)
LPOLESTR Name = L"Picture";
DISPID dispID;
disp->GetIDsOfNames(IID_NULL,&Name,1,LOCALE_USER_DEFAULT,&dispID);
// We just need to pass the IPictureDisp pointer
p1.vt = VT_DISPATCH;
p1.pdispVal = pd;
dp.cArgs=1;
dp.rgvarg=&p1;
// Make call to Invoke()
disp->Invoke(dispID,GUID_NULL,0,
DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF|DISPATCH_METHOD,
&dp,NULL,NULL,NULL);
I've tried several different calling params for the Invoke() call, but
it always fails. The code above produces the error 0x80020004,
"Paramater not found".
not having any luck. Can anyone tell me what is wrong with this code,
or show me a better example of how to set the
"CommandBarButton.Picture" property from an Outlook 2002 Add-in?
Note - I've removed error checking and tried to compress code snippet
as much as possible.
// Some variables
// NOTE - "disp" is an IDispatch interface of a CommandBarButton
DISPPARAMS dp={NULL,NULL,0,0};
IPictureDisp *pd;
PICTDESC pdesc;
VARIANT p1;
// Create a IPictureDisp from a TBitmap (bmp, initialized earlier)
memset(&pdesc,0,sizeof(pdesc));
pdesc.cbSizeofstruct = sizeof(pdesc);
pdesc.picType = PICTYPE_BITMAP;
pdesc.bmp.hbitmap = bmp->Handle;
pdesc.bmp.hpal = bmp->Palette;
OleCreatePictureIndirect(&pdesc,IID_IPictureDisp,FALSE,(void**)&pd);
// Get the Dispatch ID for the "Picture" property
// dispID = 1610940430, which should be correct (from MSDN)
LPOLESTR Name = L"Picture";
DISPID dispID;
disp->GetIDsOfNames(IID_NULL,&Name,1,LOCALE_USER_DEFAULT,&dispID);
// We just need to pass the IPictureDisp pointer
p1.vt = VT_DISPATCH;
p1.pdispVal = pd;
dp.cArgs=1;
dp.rgvarg=&p1;
// Make call to Invoke()
disp->Invoke(dispID,GUID_NULL,0,
DISPATCH_PROPERTYPUT|DISPATCH_PROPERTYPUTREF|DISPATCH_METHOD,
&dp,NULL,NULL,NULL);
I've tried several different calling params for the Invoke() call, but
it always fails. The code above produces the error 0x80020004,
"Paramater not found".