CTabbedPane Class

 

The new home for Visual Studio documentation is Visual Studio 2017 Documentation on docs.microsoft.com.

The latest version of this topic can be found at CTabbedPane Class.

Implements the functionality of a pane with detachable tabs.

class CTabbedPane : public CBaseTabbedPane  

Public Constructors

NameDescription
CTabbedPane::CTabbedPaneDefault constructor.

Public Methods

NameDescription
CTabbedPane::DetachPane(Overrides CBaseTabbedPane::DetachPane.)
CTabbedPane::EnableTabAutoColorEnables or disables automatic coloring of tabs.
CTabbedPane::FloatTabFloats a pane, but only if the pane currently resides in a detachable tab. (Overrides CBaseTabbedPane::FloatTab.)
CTabbedPane::GetTabAreaReturns the size and position of the tab area within the tabbed window.
CTabbedPane::GetTabWnd
CTabbedPane::HasAutoHideModeDetermines whether the tabbed pane can be switched to autohide mode. (Overrides CBaseTabbedPane::HasAutoHideMode.)
CTabbedPane::IsTabLocationBottomDetermines whether the tabs are located at the bottom of the window.
CTabbedPane::ResetTabsResets all tabbed panes to the default state.
CTabbedPane::SetTabAutoColorsSets a list of custom colors that can be used when the auto color feature is enabled.

Data Members

NameDescription
CTabbedPane::m_bTabsAlwaysTopThe default location for tabs in the application.
CTabbedPane::m_pTabWndRTCRuntime class information for a custom CMFCTabCtrl-derived object.

The framework automatically creates an instance of this class when a user attaches one pane to another by pointing to the caption of the second pane. All of the tabbed panes that are created by the framework have an ID of -1.

To specify regular tabs instead of Outlook-style tabs, pass the AFX_CBRS_REGULAR_TABS style to the CDockablePane::CreateEx method.

If you create a tabbed pane with detachable tabs, the pane may be destroyed automatically by the framework, so you should not store the pointer. To get a pointer to the tabbed pane, call the CBasePane::GetParentTabbedPane method.

In this example we create a CTabbedPane object. Next, we use CBaseTabbedPane::AddTab to attach additional tabs.

CTabbedPane* pTabbededBar = new CTabbedPane (TRUE);

if (!pTabbededBar->Create (_T(""),
    this,
    CRect (0,
    0,
    200,
    200),  
    TRUE, 
 (UINT) -1,  
    WS_CHILD | WS_VISIBLE | WS_CLIPSIBLINGS |  
    WS_CLIPCHILDREN | CBRS_LEFT |    
    CBRS_FLOAT_MULTI)) 
{  
    TRACE0("Failed to create Solution Explorer bar\n");

    return FALSE;      // fail to create  
}  
 
pTabbededBar->AddTab (&m_wndClassView);
pTabbededBar->AddTab (&m_wndResourceView);

pTabbededBar->AddTab (&m_wndFileView);
pTabbededBar->EnableDocking(CBRS_ALIGN_ANY);

DockPane(pTabbededBar);

Another way to create a tabbed control bar object is to use CDockablePane::AttachToTabWnd. The AttachToTabWnd method dynamically creates a tabbed pane object using runtime class information set by CDockablePane::SetTabbedPaneRTC.

In this example we create a tabbed pane dynamically, attach two tabs, and make the second tab non-detachable.

DockPane(&m_wndClassView);

CTabbedPane* pTabbedBar = NULL;  
m_wndResourceView.AttachToTabWnd (&m_wndClassView,
    DM_SHOW,
    TRUE,  
 (CDockablePane**) &pTabbedBar);

m_wndFileView.AttachToTabWnd (pTabbedBar,
    DM_SHOW,
    TRUE,  
 (CDockablePane**) &pTabbedBar);

pTabbedBar->GetUnderlyingWindow ()->EnableTabDetach (1,
    FALSE);

CObject

CCmdTarget

CWnd

CBasePane

CPane

CDockablePane

CBaseTabbedPane

CTabbedPane

Header: afxTabbedPane.h

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual BOOL DetachPane(
    CWnd* pBar,  
    BOOL bHide = FALSE);

Parameters

[in] pBar
[in] bHide

Return Value

Remarks

Enables or disables automatic coloring of tabs.

static void EnableTabAutoColor(BOOL bEnable = TRUE);

Parameters

[in] bEnable
TRUE to enable auto coloring of tabs; otherwise, FALSE.

Remarks

Use this static method to enable or disable automatic coloring of tabs in all tabbed panes in the application. When this feature is enabled, each tab is filled by its own color. You can find the list of colors that are used to color the tabs by calling the CMFCBaseTabCtrl::GetAutoColors method.

You can specify the list of colors that will be used for tabs by calling CTabbedPane::SetTabAutoColors.

By default, this option is disabled.

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual BOOL FloatTab(
    CWnd* pBar,  
    int nTabID,  
    AFX_DOCK_METHOD dockMethod,  
    BOOL bHide = FALSE);

Parameters

[in] pBar
[in] nTabID
[in] dockMethod
[in] bHide

Return Value

Remarks

Returns the size and position of the tab area in the tabbed window.

virtual void GetTabArea(
    CRect& rectTabAreaTop,  
    CRect& rectTabAreaBottom) const;  

Parameters

[out] rectTabAreaTop
Contains the size and position, in screen coordinates, of the top tab area.

[out] rectTabAreaBottom
Contains the size and position, in screen coordinates, of the bottom tab area.

Remarks

The framework calls this method to determine how to dock a pane that a user is dragging. When the user drags a pane over the tab area of the target pane, the framework tries to add it as a new tab of the target pane. Otherwise, it tries to dock the pane to the side of the target pane, which involves creating a new pane container with a pane divider that separates the two panes.

Override this method in a CTabbedPane-derived class to change this behavior.

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

CMFCTabCtrl* GetTabWnd() const;  

Return Value

Remarks

This topic is included for completeness. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.

virtual BOOL HasAutoHideMode() const;  

Return Value

Remarks

Determines whether the tabs are located at the bottom of the window.

virtual BOOL IsTabLocationBottom() const;  

Return Value

TRUE if the tab area is located at the bottom of the tabbed window; otherwise, FALSE.

Remarks

The default location for tabs in the application.

AFX_IMPORT_DATA static BOOL m_bTabsAlwaysTop;  

Remarks

Set this static member to TRUE to force all tabs in the application to be displayed at the top of the tabbed pane.

You must set this value before a tabbed pane has been created.

The default value is FALSE.

Runtime class information for a custom CMFCTabCtrl-derived object.

AFX_IMPORT_DATA static CRuntimeClass* m_pTabWndRTC;  

Remarks

Set this static member variable to a pointer to the runtime class information of a CMFCTabCtrl-derived object if you are using a custom tabbed window inside a tabbed pane.

Resets all tabbed panes to the default state.

static void ResetTabs();

Remarks

Call this method to revert all tabbed panes to their default state. When called, this method resets the border sizes and auto color state of all tabbed panes.

Sets a list of custom colors that are used when the auto color feature is enabled.

static void SetTabAutoColors(const CArray<COLORREF, COLORREF>& arColors);

Parameters

[in] arColors
Contains the array of colors to set.

Remarks

Use this method to customize the list of colors that are used when the auto color feature is enabled. This is a static function and affects all tabbed panes in your application.

Use CTabbedPane::EnableTabAutoColor to enable or disable the auto color feature.

Hierarchy Chart
Classes
CDockablePane Class
CBaseTabbedPane Class
CMFCOutlookBar Class

Show: