Changing CommandBarButton image at runtime

T

Tom at GSD

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);
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top