Making a Bitmap Button

Click here to change the theme.

The CBitmapButton MFC class makes it easy to create buttons with custom bitmaps. It is easy to use if you know how to. The documentation says to use CBitmapButton::AutoLoad but I do not understand how to use it. The following is what worked for me.

  1. Set the "Owner draw" style for the button on
  2. Use the ClassWizard to create a class derived from CButton
  3. In the header of the derived class change the class from CButton to CBitmapButton
  4. Use ClassWizard again to create a "control category" member variable for the button; ensure that the class is the derived class you just created
  5. In the dialog's OnInitDialog use CBitmapButton::LoadBitmaps to load one or more bitmaps

An example of LoadBitmaps is:

if (!m_ctlPictureButton1.LoadBitmaps(_T("IMAGE1UP"), _T("IMAGE1DOWN"), _T("IMAGE1FOCUS")))
	MessageBox("Button1 pictures are not loaded");