Partager via


CTabCtrl::Create

Creates a tab control and attaches it to an instance of a CTabCtrl object.

virtual BOOL Create( 
  DWORD dwStyle, 
  const RECT& rect, 
  CWnd* pParentWnd, 
  UINT nID  
);

Parameters

  • dwStyle
    Specifies the tab control's style. Apply any combination of tab control styles, described in the Windows SDK. See Remarks for a list of window styles that you can also apply to the control.

  • rect
    Specifies the tab control's size and position. It can be either a CRect object or a RECT structure.

  • pParentWnd
    Specifies the tab control's parent window, usually a CDialog. It must not be NULL.

  • nID
    Specifies the tab control's ID.

Return Value

TRUE if initialization of the object was successful; otherwise FALSE.

Remarks

You construct a CTabCtrl object in two steps. First, call the constructor, and then call Create, which creates the tab control and attaches it to the CTabCtrl object.

In addition to tab control styles, you can apply the following window styles to a tab control:

  • WS_CHILD   Creates a child window that represents the tab control. Cannot be used with the WS_POPUP style.

  • WS_VISIBLE   Creates a tab control that is initially visible.

  • WS_DISABLED   Creates a window that is initially disabled.

  • WS_GROUP   Specifies the first control of a group of controls in which the user can move from one control to the next with the arrow keys. All controls defined with the WS_GROUP style after the first control belong to the same group. The next control with the WS_GROUP style ends the style group and starts the next group (that is, one group ends where the next begins).

  • WS_TABSTOP    Specifies one of any number of controls through which the user can move by using the TAB key. The TAB key moves the user to the next control specified by the WS_TABSTOP style.

To create a tab control with extended window styles, call CTabCtrl::CreateEx instead of Create.

Example

// Assuming you have a member variable m_TabCtrl, that is a CTabCtrl 
// object, you can use the following to create a tab control.

m_TabCtrl.Create(TCS_TABS | TCS_FIXEDWIDTH | WS_CHILD | WS_VISIBLE,
   rect, this, IDC_MYTAB);

// This creates a tab control with the given styles, and with 
// an ID of IDC_MYTAB.

Requirements

Header: afxcmn.h

See Also

Reference

CTabCtrl Class

Hierarchy Chart

CTabCtrl::CTabCtrl