Click here to Skip to main content
15,886,026 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I want load different bitmaps on different button states .For Instance when button is clicked ,mouse hovering and normal state.Like this I want to load three different bitmap on three states.Usually this can be done by CBitmap:SetBitmap() ,and I am able to load in all the ways I want.But the problem is when I checked running my application on windows XP machine then the bitmaps are not getting loaded.

I am not at all sure why they are not getting loaded.Can anyone please let me know is this problem with my bitmap loading.If so,I able to load them on other operating systems right.

If this is the not the way to get the bitmaps,then kindly let me know how can I load bitmap such that I must be able to load and setbitmaps on all operating systems.

Please find the code I implemented for setting the bitmap on to the button,similarly done for mouse hovering and button click,

C++
CButton *pMyButton = (CButton*)GetDlgItem(IDC_BTN_STANDARD);
BitmapStd.LoadBitmap(IDB_STANDARD_IDEAL_BMP);
HBITMAP hBitmap = (HBITMAP)BitmapStd.GetSafeHandle();
pMyButton ->SetBitmap(hBitmap);



Thanks in Advance.
Posted
Updated 27-Oct-14 4:15am
v2

1 solution

I do it with something like this:
C++
HBITMAP			hBmp;

// load the bitmap from the program's resources
hBmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(222));

// send the message to the button, to repaint itself
SendMessage(GetDlgItem(hDlg,IDC_PWBUTTON), BM_SETIMAGE, (WPARAM)IMAGE_BITMAP, (LPARAM)hBmp);
}

The button is defined in the resource file thus:
C++
PUSHBUTTON "&Password",	IDC_PWBUTTON,	 13, 48, 40,  40, BS_BITMAP
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900