0

I have a CButton object. I added a bitmap file to the resource editor. I do the following:

CButton m_btnClose; (in header file)

if (GetDlgItem(IDC_BUTTON_CLOSE))
{
    HBITMAP hBMP = LoadBitmapW(AfxGetResourceHandle(), MAKEINTRESOURCE(IDC_BITMAP_CLOSE));
    m_btnClose.ModifyStyle(0, BS_BITMAP);
    m_btnClose.SetBitmap(hBMP);
}

The bitmap is actually loaded and applied to the button, but you can clearly see the regular button background behind it. Ignore the fact the button background is not the same color as the surrounding area.

enter image description here

user8694-03
  • 359
  • 3
  • 15
  • Basically, two options: (a) Stretch the bitmap to cover the whole button (tricky); (b) resize the button to 'fit' the bitmap (involves some work). – Adrian Mole Apr 03 '21 at 02:56
  • Thanks for that information. I can't believe there's no way to hide the normal appearance of the button. Like possibly just ModifyStyle with the BS_BITMAP flag, auto hiding it, or an additional flag BS_HIDE_APPEARANCE. Anyway, I guess I'll resize the button to be equal to the dimensions of the bitmap. Thanks again. – user8694-03 Apr 03 '21 at 03:00

0 Answers0