CTabView Class
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
Members
Public Methods
Name |
Description |
---|---|
Adds a new view to the tab control. |
|
Returns the index of the specified view in the tab control. |
|
Returns a pointer to the currently active view |
|
Returns a reference to the tab control associated with the view. |
|
Removes the view from the tab control. |
|
Makes a view active. |
Protected Methods
Name |
Description |
---|---|
Called by the framework when creating a tab view to determine whether the tab view has a shared horizontal scroll bar. |
|
Called by the framework when the tab view is made active or inactive. |
Remarks
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.
Example
The following example shows how CTabView is used in the TabbedView sample.
class CTabbedViewView : public CTabView
{
protected: // create from serialization only
CTabbedViewView();
DECLARE_DYNCREATE(CTabbedViewView)
// Attributes
public:
CTabbedViewDoc* GetDocument();
// Operations
public:
// Overrides
public:
virtual void OnDraw(CDC* pDC); // overridden to draw this view
virtual BOOL PreCreateWindow(CREATESTRUCT& cs);
protected:
virtual BOOL OnPreparePrinting(CPrintInfo* pInfo);
virtual void OnBeginPrinting(CDC* pDC, CPrintInfo* pInfo);
virtual void OnEndPrinting(CDC* pDC, CPrintInfo* pInfo);
BOOL IsScrollBar () const
{
return TRUE;
}
// Implementation
public:
virtual ~CTabbedViewView();
#ifdef _DEBUG
virtual void AssertValid() const;
virtual void Dump(CDumpContext& dc) const;
#endif
protected:
afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
afx_msg BOOL OnEraseBkgnd(CDC* pDC);
afx_msg void OnContextMenu(CWnd*, CPoint point);
afx_msg void OnFilePrintPreview();
DECLARE_MESSAGE_MAP()
};
Requirements
Header: afxTabView.h
See Also
Concepts
Reference
Other Resources
Change History
Date |
History |
Reason |
---|---|---|
March 2009 |
Revamped remarks. |
Customer feedback. |