How to change a CBitmapButton Image on Mouse Over in VC++/MFC

hi alll
      i have  an application in which i am using a CBitmapButton i want that when move mouse over button then the button should change image.
    for that i am doing the following things

1- i have created a new class Ccustombutton derived from CBitmapButton. in this i am handling mouse move handler.

2- in mouse move handler i am using LoadBitmaps(IDC_BMP1,IDC_BMP2,IDC_BMP3,IDC_BMP4)


But i am not able to do this


please tell me how to do this
 
RuhelaAsked:
Who is Participating?
 
ZoppoConnect With a Mentor Commented:
Hi Ruhela,

there's no need to load the bittmaps in a mouse move handler - just load them after you created the button, i.e. if the button is used in a dialog in OnInitDialog.

Further you have to ensure that the BS_OWNERDRAW style for the button is set - this can be done in resource editor.

ZOPPO
0
 
pgnatyukCommented:
And do not forget to draw the button.
HOWTO: How to Use CBitmapButton to Resize a Bitmap to Fit a Button
http://support.microsoft.com/kb/134421


0
 
ZoppoCommented:
> And do not forget to draw the button.
this is only needed if the bitmaps need to be stretched to fit - if they are drawn correctly without stretching the default implementation is ok ...
0
 
AndyAinscowFreelance programmer / ConsultantCommented:
I think the MFC feature pack (requires VS2008) has a new MFC button - this supports a 'hot' image that is displayed when the mouse is over the button.  That sounds exactly like what you are asking about.
0
 
RuhelaAuthor Commented:
solved
0
All Courses

From novice to tech pro — start learning today.