INFO: Using CBitmapButton in CDialogBar and CFormView

Article translations Article translations
Article ID: 98041 - View products that this article applies to.
This article was previously published under Q98041
This article has been archived. It is offered "as is" and will no longer be updated.
To attach a CBitmapButton object to a button in a dialog box, call the CBitmapButton::AutoLoad() function in the OnInitDialog() function for the dialog box. Note, that the CDialogBar and CFormView classes are not derived from the CDialog class and do not have an OnInitDialog() function.

To use a CBitmapButton with a CDialogBar, override the Create() function and call AutoLoad() after calling the base class version of Create(). In the following code, which demonstrates this process, the CMyDialogBar class is derived from CDialogBar and m_MyBitmapButton is a CBitmapButton member of CMyDialogBar:
   BOOL CMyDialogBar::Create(CWnd* pParent, UINT nIDTemplate,
                             UINT nStyle, UINT nID)
   {
      // Call base class create to create the dialog bar window.
      BOOL bReturn = CDialogBar::Create(pParent, nIDTemplate,
                                        nStyle, nID);
      // Load bitmaps for the button and attach
      // to the control in the dialog box.
      if (bReturn)
         m_MyBitmapButton.AutoLoad(IDC_MYBITMAPBUTTON, this);

      return bReturn;
   }
		
To use a CBitmapButton with a CFormView, call AutoLoad() in the CFormView OnInitialUpdate() function. In the following code, which demonstrates this, the CMyFormView class is derived from CFormView and m_MyBitmapButton is a CBitmapButton member of CMyFormView:
   void CMyFormView::OnInitialUpdate()
   {
      CFormView::OnInitialUpdate();
      m_MyBitmapButton.AutoLoad(IDC_MYBITMAPBUTTON, this);
   }
		
Expand all | Collapse all

Properties

Article ID: 98041 - Last Review: October 26, 2013 - Revision: 4.0
Applies to
  • Microsoft Foundation Class Library 4.2, when used with:
    • Microsoft Visual C++ 1.0 Professional Edition
    • Microsoft Visual C++ 1.52 Professional Edition
    • Microsoft Visual C++ 2.1
    • Microsoft Visual C++ 2.2
    • Microsoft Visual C++ 4.0 Standard Edition
Keywords: 
kbnosurvey kbarchive kbdocview kbinfo kbmfcctrlbar kbuidesign KB98041

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com