Outlook Banter

Outlook Banter (http://www.outlookbanter.com/)
-   Add-ins for Outlook (http://www.outlookbanter.com/add-ins-outlook/)
-   -   Changing CommandBarButton image at runtime (http://www.outlookbanter.com/add-ins-outlook/20274-changing-commandbarbutton-image-runtime.html)

Tom at GSD July 10th 06 03:35 PM

Changing CommandBarButton image at runtime
 
Hi,

I have developed a ATL C++ addin (Outlook 2002 & 2003) and I have run into
an issue. I need to change the state of a button at runtime and part of this
requirement is switching the button image. I have tried two methods and both
exhibit the same symptom. The symptom is that the image does not change
during normal conditions - however if I set a break poiint within in my
debugger the Image does change. Is seems that this cause the control to
redraw the image - probably because the control is invalidated and updated.
So my question becomes how can I do this programatically? I have tried a few
things to get the button control to redraw, but I believe I must be missing
something. Is there a method that will allow me to force the control to
redraw itself?
Below are the methods I have used ...

1.

OpenClipboard(NULL);
EmptyClipboard();
SetClipboardData(CF_BITMAP, (HANDLE)hBmp);
CloseClipboard();
spButton-PasteFace();


2.

PICTDESC pdBmp;
pdBmp.cbSizeofstruct = sizeof(PICTDESC);
pdBmp.picType = PICTYPE_BITMAP;
pdBmp.bmp.hbitmap = hBmp;
pdBmp.bmp.hpal = 0;

IPictureDispPtr pPic;
::OleCreatePictureIndirect(&pdBmp, IID_IPictureDisp, TRUE, (LPVOID*) &pPic);
spButton-PutPicture(pPic);



All times are GMT +1. The time now is 05:04 AM.

Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com