description | title | ms.date | f1_keywords | helpviewer_keywords | ms.assetid | ||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
Learn more about: CTabView Class |
CTabView Class |
11/04/2016 |
|
|
8e6ecd9d-d28d-432b-8ec8-0446f0204d52 |
The CTabView
class simplifies the use of the tab control class ( CMFCTabCtrl) in applications that use MFC's document/view architecture.
class CTabbedView : public CView
Name | Description |
---|---|
CTabView::AddView | Adds a new view to the tab control. |
CTabView::FindTab | Returns the index of the specified view in the tab control. |
CTabView::GetActiveView | Returns a pointer to the currently active view |
CTabView::GetTabControl | Returns a reference to the tab control associated with the view. |
CTabView::RemoveView | Removes the view from the tab control. |
CTabView::SetActiveView | Makes a view active. |
Name | Description |
---|---|
CTabView::IsScrollBar | Called by the framework when creating a tab view to determine whether the tab view has a shared horizontal scroll bar. |
CTabView::OnActivateView | Called by the framework when the tab view is made active or inactive. |
This class makes it easy to put a tabbed view into a document/view application. CTabView
is a CView
-derived class that contains an embedded CMFCTabCtrl
object. CTabView
handles all messages required to support the CMFCTabCtrl
object. Simply derive a class from CTabView
and plug it into your application, then add CView
-derived classes by using the AddView
method. The tab control will display those views as tabs.
For example, you might have a document that can be represented in different ways: as a spreadsheet, a chart, an editable form, and so on. You can create individual views drawing the data as needed, insert them into your CTabView
-derived object and have them tabbed without any additional coding.
TabbedView Sample: MFC Tabbed View Application illustrates usage of CTabView
.
The following example shows how CTabView
is used in the TabbedView sample.
[!code-cppNVC_MFC_TabbedView#1]
Header: afxTabView.h
Adds a view to the tab control.
int AddView(
CRuntimeClass* pViewClass,
const CString& strViewLabel,
int iIndex=-1,
CCreateContext* pContext=NULL);
pViewClass
[in] A pointer to a runtime class of the inserted view.
strViewLabel
[in] Specifies the tab's text.
iIndex
[in] Specifies the zero-based position at which to insert the view. If the position is -1 the new tab is inserted at the end.
pContext
[in] A pointer to the CCreateContext
of the view.
A view index if this method succeeds. Otherwise, -1.
Call this function to add a view to the tab control that is embedded in a frame.
Returns the index of the specified view in the tab control.
int FindTab(HWND hWndView) const;
hWndView
[in] The handle of the view.
The index of the view if it is found; otherwise, -1.
Call this function to retrieve the index of a view that has a specified handle.
Returns a pointer to the currently active view.
CView* GetActiveView() const;
A valid pointer to the active view, or NULL if there is no active view.
Returns a reference to the tab control associated with the view.
DECLARE_DYNCREATE CMFCTabCtrl& GetTabControl();
A reference to the tab control associated with the view.
Called by the framework when creating a tab view to determine whether the tab view has a shared horizontal scroll bar.
virtual BOOL IsScrollBar() const;
TRUE if the tab view should be created together with a shared scroll bar. Otherwise, FALSE.
The framework calls this method when a CTabView object is being created.
Override the IsScrollBar method in a CTabView-derived class and return TRUE if you want to create a view that has a shared horizontal scroll bar.
Called by the framework when the tab view is made active or inactive.
virtual void OnActivateView(CView* view);
view
[in] A pointer to the view.
The default implementation does nothing. Override this method in a CTabView
-derived class to process this notification.
Removes the view from the tab control.
BOOL RemoveView(int iTabNum);
iTabNum
[in] The index of the view to remove.
The index of the removed view if this method succeeds. Otherwise -1.
Makes a view active.
BOOL SetActiveView(int iTabNum);
iTabNum
[in] The zero-based index of the tab view.
TRUE if the specified view was made active, FALSE if the view's index is invalid.
For more information see CMFCTabCtrl::SetActiveTab.