Can not add bitmap image as background in C++ MFC button control


I can not add a bitmap as background on a Button Control in C++, MFC. I am using Visual Studio 2005.
I have set the button property "Bitmap" to true, and I am using the code below in
BOOL Ceduinst5Dlg::OnInitDialog(), but the button stil does not have the bitmap as a background.
I have tried adding the same code to BN_CLICKED event, then calling Invalidate(), but it again does not work.
What can I do to solve this problem?

CButton *pWnd = (CButton *) Ceduinst5Dlg::GetDlgItem(IDC_BUTTON1);
pWnd->SetBitmap(::LoadBitmap(NULL, MAKEINTRESOURCE(IDB_BITMAP1)));

Open in new window

Who is Participating?
Deepu AbrahamConnect With a Mentor R & D Engineering ManagerCommented:
You can follow the link:
Best Regards,
imladrisConnect With a Mentor Commented:
Visual Studio offers a CBitMapButton control. Is there a reason you're not using that one?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.