CButton and Bitmap Interface :: MFC
I have a simple button in a dialog box. I want to paint a bitmap on the button. I created the bitmap in Resource Editor. It is ready to be imported to the program.
How do you paint a bitmap to a button?
I tried SetBitmap(), but it wants an HBITMAP structure.
You need to call LoadBitmap()
HINSTANCE hInstance, // handle of application instance
LPCTSTR lpBitmapName // address of bitmap resource name
Programming is fun, mkay?
I have done this before. If you created the button in the dialog resource editor you can give it a name using the ClassWizard (CTRL + W). For example, you named it m_Button. Right-click the button in the resource editor and click "Properties". Find and set the style to "Bitmap". In your dialog's code, do this:
/* This is if your bitmap's resource ID is: IDB_BITMAP, for example */
bmp = LoadBitmap(GetModuleHandle(NULL), MAKEINTRESOURCE(IDB_BITMAP));