How to load bitmap on a command button in VC++How to load bitmap on a command button in VC++

How to load bitmap on a command button in VC++. i have turned on the bitmap property of the command button in design view in dialog.

my code goes like this.

CButton *a;
a= (CButton *)GetDlgItem(IDC_BUTTON1);
a->SetBitmap((HBITMAP)MAKEINTRESOURCE(IDB_BITMAP1));


but nothing happens when this code is executed . am i wrong somewhere??
please reply me immediately. i am using VC6.0
karthik1979Asked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
pkknConnect With a Mentor Commented:
Hai Karthik,
Try It...

CButton *a;
a= (CButton *)GetDlgItem(IDC_BUTTON1);
HBITMAP hBmp = LoadBitmap(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDB_BITMAP1));
a->SetBitmap(hBmp );
0
 
AxterCommented:
You have to set the IDC_BUTTON1 property to Ownwer_draw and Bitmap
0
 
karthik1979Author Commented:
I checked it .  i wrote the code on button2 click event  to load bitmap on button1. also i set the BS_OWNERDRAW style as said in MSDN .
but when i click on button 2  . button1  disappeared!! on the dialog box.


0
All Courses

From novice to tech pro — start learning today.