BOOL Create( LPCTSTR lpszCaption, DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );
Return Value
Nonzero if successful; otherwise 0.
Parameters
lpszCaption
Specifies the button control’s text.
dwStyle
Specifies the button control’s style. Apply any combination of button styles to the button.
rect
Specifies the button control’s size and position. It can be either a CRect object or a RECT structure.
pParentWnd
Specifies the button control’s parent window, usually a CDialog. It must not be NULL.
nID
Specifies the button control’s ID.
Remarks
You construct a CButton object in two steps. First call the constructor, then call Create, which creates the Windows button control and attaches it to the CButton object.
If the WS_VISIBLE style is given, Windows sends the button control all the messages required to activate and show the button.
Apply the following window styles to a button control:
Example
CButton myButton1, myButton2, myButton3, myButton4;
// Create a push button.
myButton1.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON,
CRect(10,10,100,30), pParentWnd, 1);
// Create a radio button.
myButton2.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_RADIOBUTTON,
CRect(10,40,100,70), pParentWnd, 2);
// Create an auto 3-state button.
myButton3.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_AUTO3STATE,
CRect(10,70,100,100), pParentWnd, 3);
// Create an auto check box.
myButton4.Create(_T("My button"), WS_CHILD|WS_VISIBLE|BS_AUTOCHECKBOX,
CRect(10,100,100,130), pParentWnd, 4);
CButton Overview | Class Members | Hierarchy Chart
See Also CButton::CButton