class CButton : public CWnd

The CButton class provides the functionality of Windows button control. A button control is a small, rectangular child window that can be clicked on and off. Buttons can be used alone or in groups, and can either be labeled or appear without text. A button typically changes appearance when the user clicks it.

Typical buttons are the check box, radio button, and push button. A CButton object can become any of these, according to the style specified at its initialization by the Create member function.

You create a button control in two steps. First, call the constructor CButton to construct the CButton object, then call the Create member function to create the Windows button control and attach it to the CButton object.

Construction can be a one-step process in a class derived from CButton. Write a constructor for the derived class and call Create from within the constructor.

If you want to handle the Windows notification messages sent by a CButton object to its parent (usually a class derived from CDialog or CModalDialog), add the appropriate message-map entries and message-handler member functions to the parent class to handle the messages you want to process. Potential message-map entries are:

ON_COMMAND
ON_BN_CLICKED
ON_BN_DOUBLECLICKED

If you create a CButton object within a dialog box (through a dialog resource), the CButton object is automatically destroyed when the user closes the dialog box.

If you create a CButton object within a window, you may also need to destroy it. If you create the CButton object on the stack, it is destroyed automatically. If you create the CButton object on the heap by using the new function, you must call delete on the object to destroy it when the user closes the Windows button control.

If you allocate any memory in the CButton object, override the CButton destructor to dispose of the allocations.

See Also

CWnd, CComboBox, CEdit, CListBox, CScrollBar, CStatic, CModalDialog, CDialog