CTabCtrl::Create
BOOL Create( DWORD dwStyle, const RECT& rect, CWnd* pParentWnd, UINT nID );
Return Value
TRUE if initialization of the object was successful; otherwise FALSE.
Parameters
dwStyle
Specifies the tab control’s style. Apply any combination of tab control styles 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.
Remarks
You construct a CTabCtrl object in two steps. First call the constructor, then call Create, which creates the tab control and attaches it to the CTabCtrl object.
The following styles can be applied to a tab control:
-
TCS_BUTTONS Modifies the appearance of the tabs to look like buttons.
-
TCS_FIXEDWIDTH Makes all tabs the same width. (By default, the tab control automatically sizes each tab to fit its icon.) You cannot use this style with the TCS_RIGHTJUSTIFY style.
-
TCS_FOCUSNEVER Specifies that a tab never receives the input focus.
-
TCS_FOCUSONBUTTONDOWN Specifies that a tab receives the input focus when clicked. This style is typically used only with the TCS_BUTTONS style.
-
TCS_FORCEICONLEFT Forces the icon to the left, but leaves the tab label centered. (By default, the control centers the icon and label with the icon to the left of the label.)
-
TCS_FORCELABELLEFT Left-aligns both the icon and label.
-
TCS_MULTILINE Causes a tab control to display multiple rows of tabs. Thus all tabs can be displayed at once. (By default, a tab control displays a single row of tabs.)
-
TCS_OWNERDRAWFIXED Specifies that the parent window draws the tabs in the control.
-
TCS_RIGHTJUSTIFY Right justifies tabs. (By default, tabs are left-justified within each row.)
-
TCS_SHAREIMAGELISTS Specifies that a tab control’s image lists are not destroyed when the control is destroyed.
-
TCS_TOOLTIPS Specifies that the tab control has a tool tip control associated with it.
-
TCS_TABS Tabs appear as tabs, and a border is drawn around the display area. This style is the default.
-
TCS_SINGLELINE Displays only one row of tabs. The user can scroll to see more tabs, if necessary. This style is the default.
-
TCS_RAGGEDRIGHT Does not stretch each row of tabs to fill the entire width of the control. This style is the default.
In addition, 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.
Example
// Assuming you have a member variable m_pTabCtrl, that is a CTabCtrl
// pointer, you can use the following to create a tab control.
m_pTabCtrl->Create(TCS_TABS | TCS_FIXEDWIDTH | WS_CHILD | WS_VISIBLE,
&rect, this, 0x1006);
// This creates a tab control with the given styles, and with
// an ID of 0x1006.
CTabCtrl Overview | Class Members | Hierarchy Chart
See Also CTabCtrl::CTabCtrl