CMFCBaseTabCtrl Class
Implements the base functionality for tabbed windows. For more detail see the source code located in the VC\atlmfc\src\mfc folder of your Visual Studio installation.
class CMFCBaseTabCtrl : public CWnd
Name | Description |
---|---|
CMFCBaseTabCtrl::AddIcon | |
CMFCBaseTabCtrl::AddTab | Adds a new tab to the tabbed window. |
CMFCBaseTabCtrl::ApplyRestoredTabInfo | |
CMFCBaseTabCtrl::AutoDestroyWindow | |
CMFCBaseTabCtrl::CalcRectEdit | |
CMFCBaseTabCtrl::CleanUp | |
CMFCBaseTabCtrl::ClearImageList | |
CMFCBaseTabCtrl::DetachTab | Detaches a tab from a tabbed window. |
CMFCBaseTabCtrl::EnableActivateLastActive | |
CMFCBaseTabCtrl::EnableAutoColor | Enables or disables automatic tab coloring. |
CMFCBaseTabCtrl::EnableCustomToolTips | Enables or disables custom tooltips for tabs. |
CMFCBaseTabCtrl::EnableInPlaceEdit | Enables or disables direct editing of tab labels. |
CMFCBaseTabCtrl::EnableTabDetach | Enables detachable tabs. |
CMFCBaseTabCtrl::EnableTabSwap | Enables or disables whether the user can change the tab order by using a mouse. |
CMFCBaseTabCtrl::EnsureVisible | Scrolls the tabs until the specified tab is visible. This method has no effect if the specified tab is already visible. |
CMFCBaseTabCtrl::EnterDragMode | |
CMFCBaseTabCtrl::FindTargetWnd | Returns a pane that contains a specified point. |
CMFCBaseTabCtrl::FireChangeActiveTab | |
CMFCBaseTabCtrl::FireChangingActiveTab | |
CMFCBaseTabCtrl::GetActiveTab | Returns the index of the active tab. |
CMFCBaseTabCtrl::GetActiveTabColor | Returns the background color of the active tab. |
CMFCBaseTabCtrl::GetActiveTabTextColor | Returns the text color of the active tab. |
CMFCBaseTabCtrl::GetActiveWnd | Returns a pointer the active page of the tab control. |
CMFCBaseTabCtrl::GetAutoColors | Returns a reference to the array of colors that are used for automatic coloring. |
CMFCBaseTabCtrl::GetFirstVisibleTab | Returns a pointer to the first visible tab. |
CMFCBaseTabCtrl::GetFirstVisibleTabNum | |
CMFCBaseTabCtrl::GetHighlightedTab | Returns the index of the currently highlighted tab. |
CMFCBaseTabCtrl::GetImageList | |
CMFCBaseTabCtrl::GetImageSize | |
CMFCBaseTabCtrl::GetLastVisibleTab | |
CMFCBaseTabCtrl::GetLocation | Returns a variable of the LOCATION data type that indicates where the tab area is positioned relative to the tab control. For example, on the top or on the bottom. |
CMFCBaseTabCtrl::GetMaxWindowSize | |
CMFCBaseTabCtrl::GetTabArea | Returns the size and the position of the tab area in the tabbed window. The position of the tab area is defined by using coordinates. |
CMFCBaseTabCtrl::GetTabBkColor | Returns the background color of the specified tab. |
CMFCBaseTabCtrl::GetTabBorderSize | Returns the size of the tab borders in the tab control. |
CMFCBaseTabCtrl::GetTabByID | Returns the index of the tab that is identified by a specified ID. |
CMFCBaseTabCtrl::GetTabCloseButton | |
CMFCBaseTabCtrl::GetTabFromHwnd | Returns the index of a tab that contains a specified HWND object. |
CMFCBaseTabCtrl::GetTabFromPoint | Returns the tab that contains a specified point. |
CMFCBaseTabCtrl::GetTabFullWidth | |
CMFCBaseTabCtrl::GetTabHicon | Returns the icon associated with the specified tab. |
CMFCBaseTabCtrl::GetTabID | Returns the ID of a tab by using the index of the tab. |
CMFCBaseTabCtrl::GetTabIcon | Returns the icon ID for a specified tab. |
CMFCBaseTabCtrl::GetTabLabel | Returns the text of a specified tab. |
CMFCBaseTabCtrl::GetTabRect | Retrieves the size and position of a specified tab. |
CMFCBaseTabCtrl::GetTabsHeight | |
CMFCBaseTabCtrl::GetTabsRect | |
CMFCBaseTabCtrl::GetTabTextColor | Returns the text color of a specified tab. |
CMFCBaseTabCtrl::GetTabWnd | Returns the pointer to a pane that resides on a specified tab page. |
CMFCBaseTabCtrl::GetTabWndNoWrapper | Returns the direct pointer to a control that resides on a specified tab page, even if the control has a wrapper. |
CMFCBaseTabCtrl::GetTabsNum | Returns the number of tabs that are contained in the tab control. |
CMFCBaseTabCtrl::GetToolTipCtrl | Returns a reference to the tooltip control associated with the CMFCBaseTabCtrl object. |
CMFCBaseTabCtrl::GetVisibleTabsNum | Returns the number of visible tabs. |
CMFCBaseTabCtrl::HasImage | |
CMFCBaseTabCtrl::HideSingleTab | Sets an option that hides a window tab, but only if the tabbed window displays a just one visible tab. |
CMFCBaseTabCtrl::InsertTab | Inserts a new tab. |
CMFCBaseTabCtrl::InvalidateTab | |
CMFCBaseTabCtrl::IsActiveTabCloseButton | |
CMFCBaseTabCtrl::IsAutoColor | Returns a value that indicates whether a tabbed window is in automatic-color mode. |
CMFCBaseTabCtrl::IsAutoDestroyWindow | |
CMFCBaseTabCtrl::IsColored | |
CMFCBaseTabCtrl::IsDialogControl | |
CMFCBaseTabCtrl::IsDrawNoPrefix | |
CMFCBaseTabCtrl::IsFlatFrame | Returns a value that indicates whether the frame for the tab area is flat or 3D. |
CMFCBaseTabCtrl::IsFlatTab | |
CMFCBaseTabCtrl::IsHideSingleTab | Returns a value that indicates whether the tab control is configured to hide a tab, but only if a tabbed window has just one visible tab. |
CMFCBaseTabCtrl::IsIconAdded | |
CMFCBaseTabCtrl::IsInPlaceEdit | Indicates whether users can modify the label on a tab. |
CMFCBaseTabCtrl::IsLeftRightRounded | |
CMFCBaseTabCtrl::IsMDITab | |
CMFCBaseTabCtrl::IsOneNoteStyle | Indicates whether a tabbed window displays tabs in Microsoft OneNote style. |
CMFCBaseTabCtrl::IsPtInTabArea | Checks whether a specified point exists in the tab area. |
CMFCBaseTabCtrl::IsTabCloseButtonHighlighted | |
CMFCBaseTabCtrl::IsTabCloseButtonPressed | |
CMFCBaseTabCtrl::IsTabDetachable | Indicates whether a tab is detachable. |
CMFCBaseTabCtrl::IsTabIconOnly | Indicates whether tabs display icons but not labels. |
CMFCBaseTabCtrl::IsTabSwapEnabled | Indicates whether the user can change tab positions by dragging tabs. |
CMFCBaseTabCtrl::IsTabVisible | Indicates whether a specified tab is visible. |
CMFCBaseTabCtrl::IsVS2005Style | |
CMFCBaseTabCtrl::MoveTab | |
CMFCBaseTabCtrl::OnChangeTabs | Called by the framework when the number of tabs changes. |
CMFCBaseTabCtrl::OnDragEnter | |
CMFCBaseTabCtrl::OnDragLeave | |
CMFCBaseTabCtrl::OnDragOver | |
CMFCBaseTabCtrl::OnDrop | |
CMFCBaseTabCtrl::OnRenameTab | |
CMFCBaseTabCtrl::PreTranslateMessage | Used by class CWinApp to translate window messages before they are dispatched to the TranslateMessage and DispatchMessage Windows functions. (Overrides CWnd::PreTranslateMessage.) |
CMFCBaseTabCtrl::RecalcLayout | Recalculates the internal layout of a tabbed window. |
CMFCBaseTabCtrl::RemoveAllTabs | Removes all tabs from the tabbed window. |
CMFCBaseTabCtrl::RemoveTab | Removes a tab from a tabbed window. |
CMFCBaseTabCtrl::RenameTab | |
CMFCBaseTabCtrl::ResetImageList | Resets the image list that is attached to a tabbed window. |
CMFCBaseTabCtrl::Serialize | Reads or writes this object from or to an archive. (Overrides CObject::Serialize.) |
CMFCBaseTabCtrl::SetActiveTab | Activates a tab. |
CMFCBaseTabCtrl::SetActiveTabColor | Sets the background color for the currently active tab. |
CMFCBaseTabCtrl::SetActiveTabTextColor | Sets the text color for active tabs. |
CMFCBaseTabCtrl::SetAutoColors | Sets the tab control colors that are applied in automatic color mode. |
CMFCBaseTabCtrl::SetDockingBarWrapperRTC | Sets the wrapper class that is used for any objects that are not derived from the CDockablePane Class. |
CMFCBaseTabCtrl::SetDrawNoPrefix | Enables and disables the processing of prefix characters when tab labels are drawn. |
CMFCBaseTabCtrl::SetImageList | Sets the icon image list. |
CMFCBaseTabCtrl::SetLocation | |
CMFCBaseTabCtrl::SetTabBkColor | Sets the background color for a specified tab. |
CMFCBaseTabCtrl::SetTabBorderSize | Sets a new tab border size. |
CMFCBaseTabCtrl::SetTabHicon | Sets a tab icon. |
CMFCBaseTabCtrl::SetTabIcon | Sets a tab icon ID. |
CMFCBaseTabCtrl::SetTabIconOnly | Enables and disables the "icon only" mode for a specified tab. |
CMFCBaseTabCtrl::SetTabLabel | Sets a tab label equal to a specified string value. |
CMFCBaseTabCtrl::SetTabsHeight | |
CMFCBaseTabCtrl::SetTabTextColor | Sets the text color for a specified tab. |
CMFCBaseTabCtrl::SetTabsOrder | Arranges tabs in the specified order. |
CMFCBaseTabCtrl::ShowTab | Shows or hides the specified tab. |
CMFCBaseTabCtrl::StartRenameTab | |
CMFCBaseTabCtrl::SwapTabs |
Name | Description |
---|---|
CMFCBaseTabCtrl::CreateWrapper | Creates a wrapper for an object derived from CWnd that is not derived from CDockablePane . To dock a CMFCBaseTabCtrl object, every embedded control must either have a docking wrapper or be derived from CDockablePane .You set the class of the wrapper by using SetDockingBayWrapperRTC . |
Name | Description |
---|---|
CMFCBaseTabCtrl::m_bActivateTabOnRightClick | Specifies whether tabs are selected by using a left mouse click or a right mouse click. |
CMFCBaseTabCtrl::m_bAutoDestroyWindow | Specifies whether the panes that are contained in the tabs are destroyed automatically. |
The CMFCBaseTabCtrl
class is an abstract class. Therefore, it cannot be instantiated. To create a tabbed window, you must derive a class from CMFCBaseTabCtrl
. The MFC library contains some derived class examples, two of which are CMFCTabCtrl Class and CMFCOutlookBarTabCtrl Class.
Starting with Visual Studio 2015, this class supports Microsoft Active Accessibility.
The following tips pertain to the CMFCBaseTabCtrl Class
and any classes that inherit from it:
If you enable detachable tabs, do not keep pointers to the tabbed windows. These detachable tabs can be created and destroyed dynamically. Therefore, pointers can become invalid.
You can configure the tab control so that users can move tabs dynamically on a tab control by using the mouse. This functionality is built into the
CMFCBaseTabCtrl
class. To enable it, call CMFCBaseTabCtrl::EnableTabSwap.By default, tabs are detachable when you add them to a tab control. You can also add non-detachable tabs by using CMFCBaseTabCtrl::AddTab. If you set the parameter
bDetachable
toFALSE
, the tab will not be detachable. You can also change whether tabs are detachable by calling the method CMFCBaseTabCtrl::EnableTabDetach.Objects that are derived from the CWnd Class can be put on a dockable control bar or dockable tab. For the whole control to be docked, you must make the
CWnd
object dockable. To accomplish this, MFC uses a wrapper class. This wrapper class is the CDockablePaneAdapter Class. AnyCWnd
objects that are added to a dockable control bar or dockable tab will be wrapped inside aCDockablePaneAdapter
object. You can disable the automatic wrapping by setting the parameterm_bEnableWrapping
of yourCMFCBaseTablCtrl
object toFALSE
. You can also change the class that your application will use as a wrapper by using the method CMFCBaseTabCtrl::SetDockingBarWrapperRTC.
Header: afxbasetabctrl.h
Adds an icon to the list of icons in the protected CMap m_mapAddedIcons
member.
void AddIcon(
HICON hIcon,
int iIcon);
hIcon
[in] A handle to the icon to be added.
iIcon
[in] Zero-based index of the icon in the protected CImageList m_Images
member.
Adds a new tab to the tab control.
virtual void AddTab(
CWnd* pTabWnd,
LPCTSTR lpszTabLabel,
UINT uiImageId = (UINT)-1,
BOOL bDetachable = TRUE);
virtual void AddTab(
CWnd* pTabWnd,
UINT uiResTabLabel,
UINT uiImageId = (UINT)-1,
BOOL bDetachable = TRUE);
pTabWnd
[in] A pointer to the window that this method represents as a new tab.
lpszTabLabel
[in] A string that contains the label for the new tab.
uiImageId
[in] An image ID from the image list. The tab control uses this image as the icon for the new tab.
uiResTabLabel
[in] The resource ID for the label.
bDetachable
[in] A Boolean parameter that determines whether the new tab is detachable.
If pTabWnd points to an object that is not derived from the CDockablePane Class and if bDetachable is TRUE, the framework automatically creates a wrapper for the pTabWnd object. The wrapper makes the pTabWnd object detachable. By default, the wrapper is an instance of the CDockablePaneAdapter Class. If the functionality offered by the default wrapper is unacceptable, use the CMFCBaseTabCtrl::SetDockingBarWrapperRTC method to specify a different wrapper.
virtual void ApplyRestoredTabInfo(BOOL bUseTabIndexes = FALSE);
[in] bUseTabIndexes
void AutoDestroyWindow(BOOL bAutoDestroy = TRUE);
[in] bAutoDestroy
virtual void CalcRectEdit(CRect& rectEdit);
[in] rectEdit
virtual void CleanUp();
virtual void ClearImageList();
Creates a wrapper for a frame window that is derived from the CWnd Class but is not derived from the CDockablePane Class.
virtual CWnd* CreateWrapper(
CWnd* pWndToWrap,
LPCTSTR lpszTabLabel,
BOOL bDetachable);
pWndToWrap
[in] A pointer to the frame window that is wrapped.
lpszTabLabel
[in] A string that contains the label for the window.
bDetachable
[in] A Boolean parameter that indicates whether the window is detachable.
A pointer to wrapper derived from the CDockablePane
class if CreateWrapper
successfully creates a wrapper class for pWndToWrap. If the method fails, it returns pWndToWrap.
A tabbed window can dock any object derived from CWnd
. However, in order for a CMFCBaseTabCtrl Class
object to be dockable, each object on the CMFCBaseTabCtrl
must be detachable. Therefore, CMFCBaseTabCtrl
automatically wraps any objects that are not derived from CDockablePane
.
By default, the CMFCBaseTabCtrl
creates instances of the CDockablePaneAdapter Class. To change the wrapper's default class, call CMFCBaseTabCtrl::SetDockingBarWrapperRTC.
If pWndToWrap is derived from CDockablePane
, this method will not create a wrapper. Instead, it will fail and return pWndToWrap.
The framework calls this method to detach a tab from the tab control.
virtual BOOL DetachTab(
AFX_DOCK_METHOD dockMethod,
int nTabNum = -1,
BOOL bHide = FALSE);
dockMethod
[in] An enumerated data type provided by the CBasePane Class. This data type specifies the method that was used to detach the tab.
nTabNum
[in] The zero-based index of the tab to be detached.
bHide
[in] A Boolean parameter that indicates whether the framework should hide the detached tab.
Nonzero if successful; otherwise 0.
If the tab specified by nTabNum is non-detachable, this function fails and returns FALSE.
void EnableActivateLastActive(BOOL bLastActive = TRUE);
[in] bLastActive
Controls whether the framework uses the automatic background colors when drawing a tab.
void EnableAutoColor(BOOL bEnable = TRUE);
bEnable
[in] A Boolean parameter that determines whether the framework uses automatic colors.
A tab control has an array of several predefined colors. When the framework uses automatic colors, each tab in a series of tabs is assigned the next color from this array.
By default, the automatic colors are determined by the library-defined colors. You can provide a custom array of colors by calling CMFCBaseTabCtrl::SetAutoColors.
Enables custom tooltips for the tab control.
BOOL EnableCustomToolTips(BOOL bEnable = TRUE);
bEnable
[in] A Boolean that determines whether to use custom tooltips.
TRUE if successful; otherwise FALSE.
If custom tooltips are enabled, the tab control sends the AFX_WM_ON_GET_TAB_TOOLTIP message to the main frame. If you want to support custom tooltips in your application, the main frame window must handle this method and provide the custom tooltip text. For more information about providing custom tooltip text, see CMFCTabToolTipInfo Structure.
Enables direct editing of the tab labels by the user.
virtual void EnableInPlaceEdit(BOOL bEnable) = 0;
bEnable
[in] A Boolean parameter that specifies whether to enable direct editing of the tab labels.
By default, direct editing of the tab labels is disabled for tab controls.
You can enable direct editing for a subset of the tabs on the tab control. To do this, override the method CMFCBaseTabCtrl::StartRenameTab
. StartRenameTab
should return a nonzero value for all tabs that support direct editing of tab labels.
In the CMFCBaseTabCtrl Class
, this method is a pure virtual function and has no implementation. If you derive a class from CMFCBaseTabCtrl
, you must implement this function.
Enables detachable tabs.
virtual BOOL EnableTabDetach(
int iTab,
BOOL bEnable);
iTab
[in] The zero-based index of a tab.
bEnable
[in] A Boolean that indicates whether to make the tab detachable.
TRUE if successful; otherwise FALSE.
Enables the user to change the tab order using a mouse.
void EnableTabSwap(BOOL bEnable);
bEnable
[in] A Boolean that indicates whether to enable tab swapping.
When tab swapping is enabled, the user can drag a tab and change its relative position in the tab control.
Scrolls the tabs until the specified tab is visible.
virtual BOOL EnsureVisible(int iTab);
iTab
[in] The zero-based index of a tab.
Nonzero if successful; otherwise 0.
This method has no effect if the tab indicated by iTab is already visible.
By default, this method is not supported by the CMFCBaseTabCtrl Class
. You should implement this function in a custom class derived from CMFCBaseTabCtrl
if that custom tab control supports tab scrolling. This method is supported by the CMFCTabCtrl Class.
void EnterDragMode();
Identifies the pane that contains a specified point.
virtual CWnd* FindTargetWnd(const CPoint& pt) = 0;
pt
[in] A point that is defined by using client-area coordinates of the CMFCBaseTabCtrl object.
A pointer to a CWnd object if successful; otherwise NULL.
In the CMFCBaseTabCtrl
class, this method is a pure virtual function: you must implement it if you derive a class from CMFCBaseTabCtrl
.
virtual void FireChangeActiveTab(int nNewTab);
[in] nNewTab
virtual BOOL FireChangingActiveTab(int nNewTab);
[in] nNewTab
Retrieves the index of the currently active tab.
virtual int GetActiveTab() const;
The zero-based index of the active tab; -1 if there is no active tab.
Retrieves the background color of the currently active tab.
virtual COLORREF GetActiveTabColor() const;
A COLORREF value that specifies the background color of the active tab.
By default, the background color of the active tab is COLOR_WINDOW. You can change the background color for the active tab by using the method CMFCBaseTabCtrl::SetActiveTabColor.
Retrieves the text color for the active tab.
virtual COLORREF GetActiveTabTextColor() const;
A COLORREF value that specifies the text color of the active tab.
By default, the text color for active tabs is COLOR_WINDOWTEXT. You can change the text color with the method CMFCBaseTabCtrl::SetActiveTabTextColor.
Retrieves a pointer to the currently active tab window.
virtual CWnd* GetActiveWnd() const;
A pointer to a window.
Retrieves the array of colors used for automatic coloring.
const CArray<COLORREF,COLORREF>& GetAutoColors() const;
A reference to an array of COLORREF values that the CMFCBaseTabCtrl object uses for automatic tab coloring.
By default, the framework initializes the array of colors to library-defined colors. You can provide a custom array of colors by calling the method CMFCBaseTabCtrl::SetAutoColors.
Retrieves a pointer to the first visible tab.
virtual CWnd* GetFirstVisibleTab(int& iTabNum);
virtual CWnd* GetFirstVisibleTab(
int iStartFrom,
int& iTabNum);
iTabNum
[out] A reference to an integer. This method writes the zero-based index of the first visible tab to this parameter.
iStartFrom
[in] The zero-based index of the first tab to check.
A pointer to the first visible tab if successful; otherwise NULL.
If this method fails, it writes the value -1 to iStartFrom.
If iStartFrom is larger than or equal to the number of tabs in the tab control, GetFirstVisibleTab
automatically fails.
virtual int GetFirstVisibleTabNum() const;
Retrieves the index of the currently highlighted tab.
int GetHighlightedTab() const;
The zero-based index of the highlighted tab.
virtual const CImageList* GetImageList() const;
virtual CSize GetImageSize() const;
virtual CWnd* GetLastVisibleTab(int& iTabNum);
[in] iTabNum
Retrieves the location of the tab area portion of the tab control.
Location GetLocation() const;
The location of the tab area.
Possible tab area location values are LOCATION_BOTTOM and LOCATION_TOP.
virtual CSize GetMaxWindowSize() const;
Retrieves the size and position of the tab area of the tab control.
virtual void GetTabArea(
CRect& rectTabAreaTop,
CRect& rectTabAreaBottom) const = 0;
rectTabAreaTop
[in] A reference to a CRect
object. GetTabArea
uses this object to store the size and position of the top tab area.
rectTabAreaBottom
[in] A reference to a CRect
object. GetTabArea
uses this object to store the size and position of the bottom tab area.
After GetTabArea
returns, the CRect
parameters contain the size and position of the tab area in client coordinates of the tab control. If there is no tab area at the top or bottom of the tab control, rectTabAreaTop
or rectTabAreaBottom
are empty.
In the CMFCBaseTabCtrl Class
, this method is a pure virtual function and has no implementation. If you derive a class from CMFCBaseTabCtrl
, you have to implement this function.
Retrieves the background color of the specified tab.
virtual COLORREF GetTabBkColor(int iTab) const;
iTab
[in] The zero-based index of the tab.
A COLORREF value that indicates the background color of the specified tab; -1 if iTab is out of range.
Retrieves the size of the tab borders in the tab control.
virtual int GetTabBorderSize() const;
The size of the tab border, in pixels.
The default size for the tab border is three pixels. You can change this border size with the method CMFCBaseTabCtrl::SetTabBorderSize.
Retrieves the index of a tab based on a tab ID.
virtual int GetTabByID(int id) const;
id
[in] A tab ID.
The zero-based index of a tab if it is found; -1 if the tab ID is not found.
The tab IDs are assigned automatically when tabs are added to a tab control.
CRect GetTabCloseButton() const;
Retrieves the index of the tab that contains the specified HWND object.
virtual int GetTabFromHwnd(HWND hwnd) const;
hwnd
[in] A handle to a window.
The zero-based index of the tab if successful; -1 if no tab contains hwnd.
Retrieves the tab that contains a specified point.
virtual int GetTabFromPoint(CPoint& pt) const;
pt
[in] A point in client coordinates of the tab control.
The index of the tab that contains pt; -1 if no tab contains pt.
virtual int GetTabFullWidth(int iTab) const;
[in] iTab
Returns the HICON associated with the specified tab.
virtual HICON GetTabHicon(int iTab) const;
iTab
[in] The zero-based index for the tab.
The HICON associated with a tab label if successful; NULL if there is no HICON or if the method fails.
Retrieves the icon associated with the specified tab.
virtual UINT GetTabIcon(int iTab) const;
iTab
[in] The zero-based index of the tab.
The icon ID for the specified tab if successful; -1 if the index is invalid.
The CMFCBaseTabCtrl object stores the icons in the internal CImageList object.
Retrieves the ID for a tab specified by the tab index.
int GetTabID(int iTab) const;
iTab
[in] The zero-based index of the tab.
An ID of the tab or -1 if iTab is out of range.
Retrieves the text of a tab label.
virtual BOOL GetTabLabel(
int iTab,
CString& strLabel) const;
iTab
[in] The zero-based index of the tab.
strLabel
[out] A reference to a CString
object. This method stores the label of the tab in this parameter.
TRUE if successful; FALSE otherwise.
This method fails if the index iTab is invalid.
You set the label for a tab when you create the tab by using CMFCBaseTabCtrl::AddTab. You can also change the label after creation with the method CMFCBaseTabCtrl::SetTabLabel.
Retrieves the size and position of the specified tab.
virtual BOOL GetTabRect(
int iTab,
CRect& rect) const;
iTab
[in] The zero-based index of the tab.
rect
[out] A reference to a CRect
object. This method stores the size and position of the tab in this parameter.
TRUE if successful; FALSE if the tab index is invalid.
virtual int GetTabsHeight() const;
Retrieves the number of tabs in the tab control.
virtual int GetTabsNum() const;
The number of tabs in the tab control.
virtual void GetTabsRect(CRect& rect) const;
[in] rect
Retrieves the text color for the specified tab.
virtual COLORREF GetTabTextColor(int iTab) const;
iTab
[in] The zero-based index of the tab.
A COLORREF parameter that indicates the text color of the specified tab; -1 if iTab is out of range.
Returns the pointer to the pane that resides on the specified tab.
virtual CWnd* GetTabWnd(int iTab) const;
iTab
[in] The zero-based index of a tab.
A pointer to the CWnd object that resides on the tab that iTab specifies. NULL if iTab is invalid.
The returned object is the one that the application added when it called either CMFCBaseTabCtrl::AddTab or CMFCBaseTabCtrl::InsertTab.
If the object on a tab has a wrapper, this method will return the wrapper for the object. For more information about wrappers, see CMFCBaseTabCtrl::CreateWrapper. If you want to access a pointer to the direct object without the wrapper, use the method CMFCBaseTabCtrl::GetTabWndNoWrapper.
Returns a pointer to the control that resides on a tab, even if the control has a wrapper.
virtual CWnd* GetTabWndNoWrapper(int iTab) const;
iTab
[in] The zero-based index of a tab.
A pointer to the CWnd object that resides on the specified tab; NULL if iTab is invalid.
This method retrieves a direct pointer to the CWnd
object that you added by using either the method CMFCBaseTabCtrl::AddTab or CMFCBaseTabCtrl::InsertTab. GetTabWndNoWrapper
will retrieve a pointer to the added CWnd
, even if the framework added a wrapper for the object. For more information about wrappers and the CMFCBaseTabCtrl Class, see CMFCBaseTabCtrl::CreateWrapper.
Use the method CMFCBaseTabCtrl::GetTabWnd if you do not want to ignore the wrapper class.
Retrieves a reference to the tooltip contorl.
CToolTipCtrl& GetToolTipCtrl() const;
A reference to the tooltip control.
Retrieves the number of currently visible tabs.
virtual int GetVisibleTabsNum() const;
The number of visible tabs.
virtual BOOL HasImage(int iTab) const;
[in] iTab
Sets the option to hide the tabs for the tab control when there is one visible tab.
virtual void HideSingleTab(BOOL bHide = TRUE);
bHide
[in] A Boolean that specifies whether to enable hiding single tabs.
When your application is configured to hide single tabs, the framework automatically displays tabs when a second tab is added to the tab control.
Inserts a tab into the tab control.
Virtual void InsertTab(
CWnd* pNewWnd,
LPCTSTR lpszTabLabel,
int nInsertAt,
UINT uiImageId = (UINT)-1,
BOOL bDetachable = TRUE);
virtual void InsertTab(
CWnd* pNewWnd,
UINT uiResTabLabel,
int nInsertAt,
UINT uiImageId = (UINT)-1,
BOOL bDetachable = TRUE);
pNewWnd
[in] A pointer to the window that this method adds as a new tab.
lpszTabLabel
[in] A string that contains the label for the new tab.
nInsertAt
[in] The zero-based index of the new tab.
uiImageId
[in] An image ID from the image list. The tab control uses this image as the icon for the new tab.
bDetachable
[in] A Boolean parameter that determines whether the new tab is detachable.
uiResTabLabel
[in] The resource ID for the label.
If the object indicated by pNewWnd is not derived from the CDockablePane Class and if the bDetachable parameter is TRUE, the framework creates a special wrapper for the new tab. By default, the wrapper is an instance of the CDockablePaneAdapter Class. Use the CMFCBaseTabCtrl::SetDockingBarWrapperRTC method to create a different wrapper class. Any custom wrapper class needs to be derived from CDockablePaneAdapter
.
void InvalidateTab(int iTab);
[in] iTab
virtual BOOL IsActiveTabCloseButton() const;
Determines whether the tab control is in autocolor mode.
BOOL IsAutoColor() const;
TRUE if the tab control is in autocolor mode; FALSE otherwise.
You can enable or disable the autocolor mode by using the CMFCBaseTabCtrl::EnableAutoColor method.
BOOL IsAutoDestroyWindow() const;
virtual BOOL IsColored() const;
BOOL IsDialogControl() const;
BOOL IsDrawNoPrefix() const;
Indicates whether the frame of the tab control is rendered in a flat style or in a 3D style.
virtual BOOL IsFlatFrame() const;
TRUE if the frame of the tab control is rendered in a flat style; FALSE if the frame is rendered in a 3D style.
Use CMFCTabCtrl::SetFlatFrame to change the style for the frame of the tab control.
Tab controls that use the Outlook style cannot be rendered with flat frames. This includes the CMFCOutlookBarTabCtrl Class and any classes derived from that class.
virtual BOOL IsFlatTab() const;
Determines whether the tab control hides the tab label if there is only one tab.
virtual BOOL IsHideSingleTab() const;
TRUE if the tab control hides the tab label when it has one tab; otherwise FALSE.
Use the method CMFCBaseTabCtrl::HideSingleTab to enable hiding the tab label when there is only one tab.
BOOL IsIconAdded(
HICON hIcon,
int& iIcon);
[in] hIcon
[in] iIcon
Indicates whether the tab control is configured to enable the user to dynamically modify the tab labels.
virtual BOOL IsInPlaceEdit() const;
Nonzero if in-place editing is enabled; otherwise 0.
You can enable or disable in-place editing by calling the method CMFCBaseTabCtrl::EnableInPlaceEdit.
virtual BOOL IsLeftRightRounded() const;
BOOL IsMDITab() const;
Determines whether tabs are displayed in the style of Microsoft OneNote.
virtual BOOL IsOneNoteStyle() const;
TRUE if tabs are displayed in the style of Microsoft OneNote; otherwise FALSE.
Call the method CMDIFrameWndEx::EnableMDITabs to enable the Microsoft OneNote style. You can also enable this style when you instantiate the CMFCTabCtrl Class: simply pass the style STYLE_3D_ONENOTE to the method CMFCTabCtrl::Create.
By default, the Microsoft OneNote style is not supported in a custom class derived from the CMFCBaseTabCtrl Class
. However, it is supported in the CMFCTabCtrl
class.
Determines if a point is inside the tab area.
virtual BOOL IsPtInTabArea(CPoint point) const = 0;
point
[in] The point to test.
Nonzero if the point is in the tab area; 0 otherwise.
In the CMFCBaseTabCtrl Class
, this method is a pure virtual function and has no implementation. If you derive a class from CMFCBaseTabCtrl
, you have to implement this function.
BOOL IsTabCloseButtonHighlighted() const;
BOOL IsTabCloseButtonPressed() const;
Determines whether a tab is detachable.
virtual BOOL IsTabDetachable(int iTab) const;
iTab
[in] The zero-based index of the tab to check.
TRUE if the tab is detachable; FALSE otherwise.
To make a tab detachable, use the method CMFCBaseTabCtrl::EnableTabDetach.
Determines whether a tab label contains only icons and no text.
virtual BOOL IsTabIconOnly(int iTab) const;
iTab
[in] The zero-based index of the tab.
TRUE if a tab label has only icons; FALSE otherwise.
To set the tabs in your application to display only icons, call the method CMFCBaseTabCtrl::SetTabIconOnly.
Determines whether the tab control allows the user to change tab positions by using the mouse.
BOOL IsTabSwapEnabled() const;
Nonzero if tab positions can be changed by the user; otherwise 0.
By default, users cannot change the order of tabs in a tab control. Use the CMFCBaseTabCtrl::EnableTabSwap method to enable this functionality.
Indicates whether the specified tab is visible.
virtual BOOL IsTabVisible(int iTab) const;
iTab
[in] The zero-based index of the tab to check.
Nonzero if the specified tab is visible; otherwise 0.
virtual BOOL IsVS2005Style() const;
m_bActivateTabOnRightClick
determines whether tabs are in focus when the user clicks on a tab label by using the right mouse button.
BOOL m_bActivateTabOnRightClick;
The default value for this data member is FALSE.
m_bAutoDestroyWindow
determines whether the framework automatically destroys the objects on tabs when the tabs are removed.
BOOL m_bAutoDestroyWindow;
By default, this member is FALSE.
virtual void MoveTab(
int nSource,
int nDest);
[in] nSource
[in] nDest
The framework calls this method when the number of tabs on a tab control changes.
virtual void OnChangeTabs();
By default, this method does nothing. Override this method to execute custom code when the number of tabs on the tab control changes.
virtual BOOL OnDrop(
COleDataObject*,
DROPEFFECT,
CPoint);
[in] COleDataObject*
[in] DROPEFFECT
[in] CPoint
virtual DROPEFFECT OnDragOver(
COleDataObject*,
DWORD,
CPoint);
[in] COleDataObject*
[in] DWORD
[in] CPoint
virtual void OnDragLeave();
virtual DROPEFFECT OnDragEnter(
COleDataObject*,
DWORD,
CPoint);
[in] COleDataObject*
[in] DWORD
[in] CPoint
virtual BOOL OnRenameTab(int, CString&);
[in] int
[in] CString&
virtual BOOL PreTranslateMessage(MSG* pMsg);
[in] pMsg
Recalculates the internal layout of the tab control.
virtual void RecalcLayout() = 0;
In the CMFCBaseTabCtrl Class
, this method is a pure virtual function. If you derive a class from CMFCBaseTabCtrl
, you have to implement this function.
Removes all the tabs from the tab control.
virtual void RemoveAllTabs();
If CMFCBaseTabCtrl::m_bAutoDestroyWindow is TRUE, the framework deletes all the CWnd objects attached to the removed tabs.
Removes a tab from the tab control.
virtual BOOL RemoveTab(
int iTab,
BOOL bRecalcLayout = TRUE);
iTab
[in] The zero-based index of a tab.
bRecalcLayout
[in] A Boolean parameter that specifies whether to recalculate the layout of the tab.
TRUE if the method removes the tab successfully; otherwise FALSE.
If CMFCBaseTabCtrl::m_bAutoDestroyWindow is TRUE, RemoveTab
destroys the CWnd object associated with the specified tab.
virtual BOOL RenameTab();
Resets the image list for an instance of the CMFCBaseTabCtrl Class.
void ResetImageList();
virtual void Serialize(CArchive& ar);
[in] ar
Activates the specified tab.
virtual BOOL SetActiveTab(int iTab) = 0;
iTab
[in] The zero-based index of a tab. SetActiveTab
makes the tab with this index active.
TRUE if successful; otherwise FALSE.
In the CMFCBaseTabCtrl Class
, this method is a pure virtual function. If you derive a class from CMFCBaseTabCtrl
, you have to implement this function.
Sets the background color for the active tab.
virtual void SetActiveTabColor(COLORREF clr);
clr
[in] Specifies the new background color.
The framework obtains the default background color for active tabs from the GetSysColormethod.
Sets the text color for active tabs.
virtual void SetActiveTabTextColor(COLORREF clr);
clr
[in] A COLORREF parameter that specifies the new text color.
By default, the framework obtains the text color from GetSysColor. Override this default color by using the SetActiveTabTextColor
method.
Sets the colors of the tab control that the framework uses in automatic color mode.
void SetAutoColors(const CArray<COLORREF,COLORREF>& arColors);
arColors
[in] An array of RGB colors.
If you provide a custom array of colors, the default array of colors is ignored. If the parameter arColors is empty, the framework reverts to the default array of colors.
To enable autocolor mode, use the CMFCBaseTabCtrl::EnableAutoColor method.
Sets the wrapper class that is used for any objects that are not derived from the CDockablePane Class.
void SetDockingBarWrapperRTC(CRuntimeClass* pRTC);
pRTC
[in] The runtime class information for the new wrapper class.
You add tabs to a tab control by using the methods CMFCBaseTabCtrl::AddTab and CMFCBaseTabCtrl::InsertTab. When you add a tab, each control on that tab must be dockable. Any objects that are not derived from CDockablePane
must be wrapped. AddTab
and InsertTab
create a wrapper for these objects. The default wrapper class is the CDockablePaneAdapter Class. The method SetDockingBarWrapperRTC
enables you to change the class that is used as a wrapper class. The wrapper class that you provide must be derived from CDockablePaneAdapter
.
Enables and disables the processing of prefix characters in tab labels.
void SetDrawNoPrefix(
BOOL bNoPrefix,
BOOL bRedraw = TRUE);
bNoPrefix
[in] TRUE if you want to process prefix characters; otherwise FALSE.
bRedraw
[in] TRUE if you want to redraw the tabbed window; otherwise FALSE.
A prefix character is a mnemonic character that is preceded by an ampersand (&).
Sets the icon image list for the tab control.
virtual BOOL SetImageList(
UINT uiID,
int cx = 15,
COLORREF clrTransp = RGB(255, 0, 255));
virtual BOOL SetImageList(HIMAGELIST hImageList);
uiID
[in] A bitmap resource ID. SetImageList
loads the image list from this resource.
cx
[in] The width of each image in pixels.
clrTransp
[in] A COLORREF parameter that indicates the transparent color of the image.
hImageList
[in] A handle to a preloaded image list.
Nonzero if the method was successful; 0 otherwise.
The images from the icon image list are displayed alongside the labels for the tab. To display an icon, you must specify its index when you call CMFCBaseTabCtrl::AddTab.
SetImageList
will fail if the tab control was created with a flat style. It will also fail if the framework cannot load the image indicated by uiID.
This method recalculates the height of the tab according to the image and text sizes.
virtual void SetLocation(Location location);
[in] location
Sets the background color for the specified tab.
virtual BOOL SetTabBkColor(
int iTab,
COLORREF color = (COLORREF)-1);
iTab
[in] The zero-based index of the tab.
color
[in] The color to set.
TRUE if successful; FALSE otherwise.
Sets a new border size for the tab control.
virtual void SetTabBorderSize(
int nTabBorderSize,
BOOL bRepaint = TRUE);
nTabBorderSize
[in] The new border size, in pixels.
bRepaint
[in] A Boolean parameter that indicates whether the framework redraws the control.
Sets the icon for a tab label.
virtual BOOL SetTabHicon(
int iTab,
HICON hIcon);
iTab
[in] The zero-based index of a tab. This method changes the icon for this tab.
hIcon
[in] A handle to an icon.
TRUE if successful; otherwise FALSE.
Sets the icon for a tab.
virtual BOOL SetTabIcon(
int iTab,
UINT uiIcon);
iTab
[in] The zero-based index of the tab to update.
uiIcon
[in] The icon ID for the new icon. This ID references the internal CImageList object.
TRUE if successful; otherwise FALSE.
Enables displaying only an icon (and no text label) on a specific tab.
virtual BOOL SetTabIconOnly(
int iTab,
BOOL bIconOnly = TRUE,
BOOL bShowTooltipAlways = FALSE);
iTab
[in] The zero-based index of the tab to change.
bIconOnly
[in] A Boolean parameter that determines whether to display only icons.
bShowTooltipAlways
[in] A Boolean parameter that determines whether the framework shows tooltips for a tab label that displays only icons.
TRUE if successful; otherwise FALSE.
By default, a tab control displays the icon and text label for each tab.
Sets the text for a tab label.
virtual BOOL SetTabLabel(
int iTab,
const CString& strLabel);
iTab
[in] The zero-based index of the tab to update.
strLabel
[in] A reference to a string that contains the new text for the tab label.
Nonzero if successful; 0 otherwise.
virtual void SetTabsHeight();
Arranges the tabs in the specified order.
BOOL SetTabsOrder(const CArray<int,int>& arOrder);
arOrder
[in] An array of zero-based indexes that defines the new tab order.
TRUE if successful; FAIL otherwise.
The size of the arOrder array must be equal to the number of tabs in the tab control.
Sets the text color for a specific tab.
virtual BOOL SetTabTextColor(
int iTab,
COLORREF color = (COLORREF)-1);
iTab
[in] The zero-based index of the tab.
color
[in] A COLORREF parameter that indicates the new text color.
Nonzero if successful; 0 otherwise.
Shows or hides the specified tab.
virtual BOOL ShowTab(
int iTab,
BOOL bShow = TRUE,
BOOL bRecalcLayout = TRUE,
BOOL bActivate = FALSE);
iTab
[in] The index of the tab that ShowTab
will show or hide.
bShow
[in] A Boolean parameter that indicates whether to show the tab.
bRecalcLayout
[in] A Boolean parameter that indicates whether to immediately recalculate the window layout.
bActivate
[in] A Boolean parameter that indicates whether to select the tab specified by iTab.
Nonzero if successful; otherwise 0.
The parameter bActivate only applies if bShow is TRUE. If bActivate is TRUE and if ShowTab
is successful, ShowTab
will send the message AFX_WM_CHANGE_ACTIVE_TAB to the parent of the tab window.
virtual BOOL StartRenameTab(int iTab);
[in] iTab
virtual void SwapTabs(
int nFisrtTabID,
int nSecondTabID);
[in] nFisrtTabID
[in] nSecondTabID
Hierarchy Chart
Classes
CMFCTabCtrl Class
CMFCOutlookBarTabCtrl Class