Click here to Skip to main content
15,887,135 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
QuestionHow to add tabs to CView Class? Pin
Sampath5794-Mar-18 22:42
Sampath5794-Mar-18 22:42 
AnswerRe: How to add tabs to CView Class? Pin
Victor Nijegorodov5-Mar-18 5:13
Victor Nijegorodov5-Mar-18 5:13 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 5:41
Sampath5795-Mar-18 5:41 
GeneralRe: How to add tabs to CView Class? Pin
jeron15-Mar-18 9:31
jeron15-Mar-18 9:31 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 18:41
Sampath5795-Mar-18 18:41 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu5-Mar-18 20:42
_Flaviu5-Mar-18 20:42 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 20:43
Sampath5795-Mar-18 20:43 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu5-Mar-18 22:03
_Flaviu5-Mar-18 22:03 
First of all, create an CTabbedView derived from CTabView.
C++
class CTabbedView : public CTabView
{
protected: // create from serialization only
	CTabbedView();
	DECLARE_DYNCREATE(CTabbedView)
...
};


Then, in OnCreate:

C++
int CTabbedView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CTabView::OnCreate(lpCreateStruct) == -1)
		return -1;

	m_wndTabs.DestroyWindow();
	if (! m_wndTabs.Create(CMFCTabCtrl::STYLE_3D, CRect(0, 0, 0, 0), this, 1, CMFCTabCtrl::LOCATION_BOTTOM))
	{
		TRACE(_T("Failed to create output tab window\n"));
		return -1;
	}

	m_wndTabs.SetFlatFrame();
	m_wndTabs.SetTabBorderSize(0);
	m_wndTabs.AutoDestroyWindow(TRUE);

	AddView(RUNTIME_CLASS(CYourView1), _T("Title 1"));
	AddView(RUNTIME_CLASS(CYourView2), _T("Title 2"));

	return 0;
}

and in your childframe, where you create the view inside your splitter, you can put this CTabbedView as any CView:
C++
if(! m_wndSplitterTab.CreateView(1, 0, RUNTIME_CLASS(CTabbedView), CSize(0, 0), pContext))
{
    m_wndSplitterTab.DestroyWindow();
    return FALSE;
}

Tell me if is not clear.
GeneralRe: How to add tabs to CView Class? Pin
Sampath5795-Mar-18 22:51
Sampath5795-Mar-18 22:51 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu5-Mar-18 23:21
_Flaviu5-Mar-18 23:21 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 0:26
Sampath5796-Mar-18 0:26 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 0:33
_Flaviu6-Mar-18 0:33 
GeneralMessage Closed Pin
6-Mar-18 0:44
Sampath5796-Mar-18 0:44 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 1:16
_Flaviu6-Mar-18 1:16 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 1:44
Sampath5796-Mar-18 1:44 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 1:50
_Flaviu6-Mar-18 1:50 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 4:09
Sampath5796-Mar-18 4:09 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 4:30
_Flaviu6-Mar-18 4:30 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 4:52
Sampath5796-Mar-18 4:52 
GeneralRe: How to add tabs to CView Class? Pin
Sampath57910-Mar-18 22:06
Sampath57910-Mar-18 22:06 
GeneralRe: How to add tabs to CView Class? Pin
Sampath57910-Mar-18 22:10
Sampath57910-Mar-18 22:10 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 0:36
_Flaviu6-Mar-18 0:36 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 0:45
Sampath5796-Mar-18 0:45 
GeneralRe: How to add tabs to CView Class? Pin
Sampath5796-Mar-18 20:18
Sampath5796-Mar-18 20:18 
GeneralRe: How to add tabs to CView Class? Pin
_Flaviu6-Mar-18 21:01
_Flaviu6-Mar-18 21:01 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.