Go4Expert

Go4Expert (http://www.go4expert.com/)
-   MFC (http://www.go4expert.com/forums/mfc/)
-   -   Attach a bitmap to a pushbutton using MFC (http://www.go4expert.com/forums/attach-bitmap-pushbutton-using-mfc-t7345/)

KLaminero 17Nov2007 06:52

Attach a bitmap to a pushbutton using MFC
 
Hi,

I use Microsoft Visual Studio 2005.
I have a dialog window created using Visual Studio IDE. This IDE gives me a .rc file.
I am trying to improve that dialog window by associating bitmaps to the pushbuttons.
The first thing i did was to change the "BITMAP" property to true for my pushbutton.

My line in the .rc file looks like this:
PUSHBUTTON "3",IDC_BUTTON3,31,50,17,17,BS_BITMAP

After that, I load my bitmap as a resource: Right click, add ressource, bitmap..."
In resource.h, I then have:
#define IDB_BITMAP3 140

Then I try to attach the bitmap to the button the following way:
CWnd* pMyWindow;
pMyWindow->GetDlgItem(IDC_BUTTON3);
pMyWindow->SendMessage(BM_SETIMAGE, IMAGE_BITMAP, IDB_BITMAP3);

But the button stays empty...
What did I forget?

PS:
I include

1. #include <atlwin.h>
2. ...
3. "

shabbir 17Nov2007 10:15

Re: Attach a bitmap to a pushbutton using MFC
 
You also need to handle the Paint method to draw the images.

KLaminero 18Nov2007 00:20

Re: Attach a bitmap to a pushbutton using MFC
 
Hi, thanks for your answer.

I am not sure what you mean by that though :confused:
With the IDE of visual studio i loaded my bitmap file into the project and transformed it into a resource...
So i m not sure what you mean by handling the paint method...

shabbir 18Nov2007 10:53

Re: Attach a bitmap to a pushbutton using MFC
 
When you attach a bitmap to the button it will not be set automatically but you need to be doing the painting of the bitmap into the DC of the button so that it displays correctly.


All times are GMT +5.5. The time now is 22:56.