We help IT Professionals succeed at work.

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

Medium Priority
3,984 Views
Last Modified: 2013-12-14
Hello,

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?

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

Open in new window

Comment
Watch Question

Commented:
Visual Studio offers a CBitMapButton control. Is there a reason you're not using that one?
R & D Engineering Manager
Commented:
You can follow the link:
http://www.functionx.com/visualc/controls/bmpbtn.htm
Best Regards,
DeepuAbrahamK