Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to add tabs to CView Class?

How to add tabs to CView Class?

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorialquestion
31 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • V Victor Nijegorodov

    Member 10253026 wrote:

    CMFCTabCtrl tab;
    if (!tab.Create(CMFCTabCtrl::STYLE_FLAT, CRect(150, 100, 0, 0), GetSplitterObj()->GetPane(1, 1), 1))
    {
    TRACE0("Failed to create output tab window\n");
    return -1; // fail to create
    }

    On Pane(1,1) i need to add tabs, and hence i added above piece of code to create MFC tab. Creation of tab is successful. It returned TRUE, but tab is not visible on that view(window). May i know what mistake i done in adding a tab to that CView window?

    Your CMFCTabCtrl tab; is defined locally. So it goes out of scope after you return from the method where you create the Views. Try to make the CMFCTabCtrl tab; the class member.

    S Offline
    S Offline
    Sampath579
    wrote on last edited by
    #3

    It does not help. I even tried to create a button as follows: if (!but.Create(_T("Test"),BS_PUSHBUTTON,CRect(0,0,0,0), GetSplitter0()->GetPane(1, 1),101)) { TRACE0("Failed to create output tab window\n"); return -1; // fail to create } CButton but is declared in header file. But still then button is not appeared on view neither the tab. Do i need to do anything extra?

    J 1 Reply Last reply
    0
    • S Sampath579

      It does not help. I even tried to create a button as follows: if (!but.Create(_T("Test"),BS_PUSHBUTTON,CRect(0,0,0,0), GetSplitter0()->GetPane(1, 1),101)) { TRACE0("Failed to create output tab window\n"); return -1; // fail to create } CButton but is declared in header file. But still then button is not appeared on view neither the tab. Do i need to do anything extra?

      J Offline
      J Offline
      jeron1
      wrote on last edited by
      #4

      You could try changing the style parameter to something like WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON and put some non-zero values into the CRect object.

      "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

      S 1 Reply Last reply
      0
      • J jeron1

        You could try changing the style parameter to something like WS_CHILD|WS_VISIBLE|BS_PUSHBUTTON and put some non-zero values into the CRect object.

        "the debugger doesn't tell me anything because this code compiles just fine" - random QA comment "Facebook is where you tell lies to your friends. Twitter is where you tell the truth to strangers." - chriselst "I don't drink any more... then again, I don't drink any less." - Mike Mullikins uncle

        S Offline
        S Offline
        Sampath579
        wrote on last edited by
        #5

        I did all the work flows but the tab control is not getting added on CSplitter Window in my application. First of all is it possible to add any controls on CSplitter windows?

        _ 1 Reply Last reply
        0
        • S Sampath579

          I did all the work flows but the tab control is not getting added on CSplitter Window in my application. First of all is it possible to add any controls on CSplitter windows?

          _ Offline
          _ Offline
          _Flaviu
          wrote on last edited by
          #6

          "First of all is it possible to add any controls on CSplitter windows?" Yes, inside of CSplitter you can insert CCtrlView which can host any MFC control.

          S 1 Reply Last reply
          0
          • _ _Flaviu

            "First of all is it possible to add any controls on CSplitter windows?" Yes, inside of CSplitter you can insert CCtrlView which can host any MFC control.

            S Offline
            S Offline
            Sampath579
            wrote on last edited by
            #7

            Then what's wrong in my code (provided above) which is not creating any control on it?

            _ 1 Reply Last reply
            0
            • S Sampath579

              Then what's wrong in my code (provided above) which is not creating any control on it?

              _ Offline
              _ Offline
              _Flaviu
              wrote on last edited by
              #8

              First of all, create an CTabbedView derived from CTabView.

              class CTabbedView : public CTabView
              {
              protected: // create from serialization only
              CTabbedView();
              DECLARE_DYNCREATE(CTabbedView)
              ...
              };

              Then, in OnCreate:

              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:

              if(! m\_wndSplitterTab.CreateView(1, 0, RUNTIME\_CLASS(CTabbedView), CSize(0, 0), pContext))
              {
              	m\_wndSplitterTab.DestroyWindow();
              	return FALSE;
              }
              

              Tell me if is not clear.

              S 2 Replies Last reply
              0
              • _ _Flaviu

                First of all, create an CTabbedView derived from CTabView.

                class CTabbedView : public CTabView
                {
                protected: // create from serialization only
                CTabbedView();
                DECLARE_DYNCREATE(CTabbedView)
                ...
                };

                Then, in OnCreate:

                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:

                if(! m\_wndSplitterTab.CreateView(1, 0, RUNTIME\_CLASS(CTabbedView), CSize(0, 0), pContext))
                {
                	m\_wndSplitterTab.DestroyWindow();
                	return FALSE;
                }
                

                Tell me if is not clear.

                S Offline
                S Offline
                Sampath579
                wrote on last edited by
                #9

                Thank you very much. It does not work even i followed the same code which you posted now and earlier. You can find the attached image which shows how i created the 5 views in my application using csplitterwnd class. In view 5 i need to add some tabs. I written a class CMyTabClass which derives from CTabView. i given this class as a RUNTIME_CLASS to view 5 as follows: bStatus = SpliterObj()->CreateView ( 1, 1, RUNTIME_CLASS(CMyTabClass), sizeView, pContext ); In CMyTabClass i created the tab as follows: if (!tab.Create(CMFCTabCtrl::STYLE_FLAT, CRect(150, 524, 250, 366), GetSplitter0()->GetPane(0, 0), 1)) { TRACE0("Failed to create output tab window\n"); return -1; // fail to create } Some times i feel the coordinates may be wrong(150,524,250,366) and hence the tab is located out side the view. I changed many times but still the tab is not visible in view 5. Click below for image Link: [^]

                _ 1 Reply Last reply
                0
                • S Sampath579

                  Thank you very much. It does not work even i followed the same code which you posted now and earlier. You can find the attached image which shows how i created the 5 views in my application using csplitterwnd class. In view 5 i need to add some tabs. I written a class CMyTabClass which derives from CTabView. i given this class as a RUNTIME_CLASS to view 5 as follows: bStatus = SpliterObj()->CreateView ( 1, 1, RUNTIME_CLASS(CMyTabClass), sizeView, pContext ); In CMyTabClass i created the tab as follows: if (!tab.Create(CMFCTabCtrl::STYLE_FLAT, CRect(150, 524, 250, 366), GetSplitter0()->GetPane(0, 0), 1)) { TRACE0("Failed to create output tab window\n"); return -1; // fail to create } Some times i feel the coordinates may be wrong(150,524,250,366) and hence the tab is located out side the view. I changed many times but still the tab is not visible in view 5. Click below for image Link: [^]

                  _ Offline
                  _ Offline
                  _Flaviu
                  wrote on last edited by
                  #10

                  Could you reproduce more accurate my example in your code ? For instance, in my example CRect has 0 value ... and there is more.

                  S 1 Reply Last reply
                  0
                  • _ _Flaviu

                    Could you reproduce more accurate my example in your code ? For instance, in my example CRect has 0 value ... and there is more.

                    S Offline
                    S Offline
                    Sampath579
                    wrote on last edited by
                    #11

                    I created a sample MFC application with single document template and added the Class which derived from CTabView and created another class which derives from CView. class MyTabClass : public CTabView { //this class created a window with tab control below. But not tab exactly. //Now i added below piece of code to create a tab. int OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CTabView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here AddView(RUNTIME_CLASS(CView1), _T("View1")); return 0; } } The above code created a single tab on window as shown in below image. [^] But all i need to know is how to create this same tab on Splitter Window which is shown in my first image. A great thanks for you in quick response and support. Please let me know what wrong i did in adding the tab on csplitter window.

                    _ 2 Replies Last reply
                    0
                    • S Sampath579

                      I created a sample MFC application with single document template and added the Class which derived from CTabView and created another class which derives from CView. class MyTabClass : public CTabView { //this class created a window with tab control below. But not tab exactly. //Now i added below piece of code to create a tab. int OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CTabView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here AddView(RUNTIME_CLASS(CView1), _T("View1")); return 0; } } The above code created a single tab on window as shown in below image. [^] But all i need to know is how to create this same tab on Splitter Window which is shown in my first image. A great thanks for you in quick response and support. Please let me know what wrong i did in adding the tab on csplitter window.

                      _ Offline
                      _ Offline
                      _Flaviu
                      wrote on last edited by
                      #12

                      My sample code was for splitter case ... do you want to add tab views inside an frame, or inside an splitter ?

                      S 1 Reply Last reply
                      0
                      • S Sampath579

                        I created a sample MFC application with single document template and added the Class which derived from CTabView and created another class which derives from CView. class MyTabClass : public CTabView { //this class created a window with tab control below. But not tab exactly. //Now i added below piece of code to create a tab. int OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CTabView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here AddView(RUNTIME_CLASS(CView1), _T("View1")); return 0; } } The above code created a single tab on window as shown in below image. [^] But all i need to know is how to create this same tab on Splitter Window which is shown in my first image. A great thanks for you in quick response and support. Please let me know what wrong i did in adding the tab on csplitter window.

                        _ Offline
                        _ Offline
                        _Flaviu
                        wrote on last edited by
                        #13

                        And what did exactly didn't work when you had applied my example ?

                        S 1 Reply Last reply
                        0
                        • _ _Flaviu

                          My sample code was for splitter case ... do you want to add tab views inside an frame, or inside an splitter ?

                          S Offline
                          S Offline
                          Sampath579
                          wrote on last edited by
                          #14

                          My childframe class contains 5 splitter windows. In one of splitter window i need to create tab. My app code as follows: BOOL CChildFrame::OnCreateClient ( LPCREATESTRUCT lpcs, CCreateContext* pContext ) { UNREFERENCED_PARAMETER (lpcs); CString csMessage = _T(""); CMainFrame* pMainFrame = (CMainFrame*) theApp.m_pMainWnd; // In floating views mode, do setup specific to it: // Create the appropriate view for it. switch (m_iCreationIndex) { case VIEW1: { // Create a four pane splitter window to use solely to pre-create the needed views. BOOL bStatus = GetSplitterObj()->CreateStatic ( this, 2, // rows 3 // columns ); if (FALSE == bStatus) { TRACE0 ("Failed to create splitter window.\n"); return FALSE; } // Create the five views when the first child frame is created. CSize sizeView (0,0); bStatus = GetSplitterObj()->CreateView ( 0, 0, RUNTIME_CLASS (MyScrollClass), sizeView, pContext ); //like wise view 2, view 3 , view 4 and below is view 5 bStatus = GetSplitterObj()->CreateView ( 1, 1, RUNTIME_CLASS (MyTabClass), sizeView, pContext ); } } } // Disconnect views from splitter window. // They will be attached to the appropriate // floating child frame as they are created. pView1->SetDlgCtrlID (-1); pView1->SetParent (this); pView1->ShowWindow (SW_HIDE); pView2->SetDlgCtrlID (-1); pView2->SetParent (this); pView2->ShowWindow (SW_HIDE); pView3->SetDlgCtrlID (-1); pView3->SetParent (this); pView3->ShowWindow (SW_HIDE); pView4->SetDlgCtrlID (-1); pView4->SetParent (this); pView4->ShowWindow (SW_HIDE); pView5->SetDlgCtrlID(-1); pView5->SetParent(this); pView5->ShowWindow(SW_HIDE); // Distroy the obsolete splitter window. GetSplitterObj()->SetDlgCtrlID (-1); GetSplitterObj()->SetParent (NULL); GetSplitterObj()->ShowWindow (SW_HIDE); GetSplitterObj()->DestroyWindow(); delete GetSplitterObj(); GetSplitterObj(NULL); The above piece of code created 5 splitter windows successfully. In Pane(1,1) i need to add tabs. MyTabClass is derived from CTabView. In MyTabClass, i created tab control as follows as you explained above. int MyTabClass::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CTabView::OnCreate(lpCreateStruct) == -1) return -1; if (!m_tab.Create(CMFCTabCtrl::STYLE_3D, CRect(0, 0, 0,

                          _ 1 Reply Last reply
                          0
                          • _ _Flaviu

                            And what did exactly didn't work when you had applied my example ?

                            S Offline
                            S Offline
                            Sampath579
                            wrote on last edited by
                            #15

                            On splitter window tab control not added. tab.Create() function returns true but tab control is not visible on splitter window.

                            1 Reply Last reply
                            0
                            • S Sampath579

                              My childframe class contains 5 splitter windows. In one of splitter window i need to create tab. My app code as follows: BOOL CChildFrame::OnCreateClient ( LPCREATESTRUCT lpcs, CCreateContext* pContext ) { UNREFERENCED_PARAMETER (lpcs); CString csMessage = _T(""); CMainFrame* pMainFrame = (CMainFrame*) theApp.m_pMainWnd; // In floating views mode, do setup specific to it: // Create the appropriate view for it. switch (m_iCreationIndex) { case VIEW1: { // Create a four pane splitter window to use solely to pre-create the needed views. BOOL bStatus = GetSplitterObj()->CreateStatic ( this, 2, // rows 3 // columns ); if (FALSE == bStatus) { TRACE0 ("Failed to create splitter window.\n"); return FALSE; } // Create the five views when the first child frame is created. CSize sizeView (0,0); bStatus = GetSplitterObj()->CreateView ( 0, 0, RUNTIME_CLASS (MyScrollClass), sizeView, pContext ); //like wise view 2, view 3 , view 4 and below is view 5 bStatus = GetSplitterObj()->CreateView ( 1, 1, RUNTIME_CLASS (MyTabClass), sizeView, pContext ); } } } // Disconnect views from splitter window. // They will be attached to the appropriate // floating child frame as they are created. pView1->SetDlgCtrlID (-1); pView1->SetParent (this); pView1->ShowWindow (SW_HIDE); pView2->SetDlgCtrlID (-1); pView2->SetParent (this); pView2->ShowWindow (SW_HIDE); pView3->SetDlgCtrlID (-1); pView3->SetParent (this); pView3->ShowWindow (SW_HIDE); pView4->SetDlgCtrlID (-1); pView4->SetParent (this); pView4->ShowWindow (SW_HIDE); pView5->SetDlgCtrlID(-1); pView5->SetParent(this); pView5->ShowWindow(SW_HIDE); // Distroy the obsolete splitter window. GetSplitterObj()->SetDlgCtrlID (-1); GetSplitterObj()->SetParent (NULL); GetSplitterObj()->ShowWindow (SW_HIDE); GetSplitterObj()->DestroyWindow(); delete GetSplitterObj(); GetSplitterObj(NULL); The above piece of code created 5 splitter windows successfully. In Pane(1,1) i need to add tabs. MyTabClass is derived from CTabView. In MyTabClass, i created tab control as follows as you explained above. int MyTabClass::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CTabView::OnCreate(lpCreateStruct) == -1) return -1; if (!m_tab.Create(CMFCTabCtrl::STYLE_3D, CRect(0, 0, 0,

                              _ Offline
                              _ Offline
                              _Flaviu
                              wrote on last edited by
                              #16

                              Dear member, in order to read easily, please format your code (use "code" button from above edit area). And, yes, m_tab.Create(...) return TRUE, but further more, you do nothing ...

                              S 3 Replies Last reply
                              0
                              • _ _Flaviu

                                Dear member, in order to read easily, please format your code (use "code" button from above edit area). And, yes, m_tab.Create(...) return TRUE, but further more, you do nothing ...

                                S Offline
                                S Offline
                                Sampath579
                                wrote on last edited by
                                #17

                                Hey sorry for the wrong indentation. Its working absolutely fine with same piece of code. The problem is what i mentioned earlier i.e., the coordinates what i provided does not show the tab control in my split window. I changed the values with hit and trail and some portion of tab control is visible on split window.

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

                                The values 500,-500,900,300 shown the control on my window. I need to write logic to show this control at the bottom of split window. Thanks for your support. Now, i will tweak this and try to add tabs to it. In case of any block i will post it back.

                                _ 1 Reply Last reply
                                0
                                • S Sampath579

                                  Hey sorry for the wrong indentation. Its working absolutely fine with same piece of code. The problem is what i mentioned earlier i.e., the coordinates what i provided does not show the tab control in my split window. I changed the values with hit and trail and some portion of tab control is visible on split window.

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

                                  The values 500,-500,900,300 shown the control on my window. I need to write logic to show this control at the bottom of split window. Thanks for your support. Now, i will tweak this and try to add tabs to it. In case of any block i will post it back.

                                  _ Offline
                                  _ Offline
                                  _Flaviu
                                  wrote on last edited by
                                  #18

                                  Sure. In my code I give it an empty CRect, and it work fine.

                                  S 1 Reply Last reply
                                  0
                                  • _ _Flaviu

                                    Sure. In my code I give it an empty CRect, and it work fine.

                                    S Offline
                                    S Offline
                                    Sampath579
                                    wrote on last edited by
                                    #19

                                    Please correct me if i am wrong. While creating a Split window using below statement.

                                    bStatus = GetSplitterObj()->CreateView
                                    			(
                                    				1,
                                    				1,
                                    				RUNTIME\_CLASS(CMyTabClass),
                                    				sizeView,
                                    				pContext
                                    			);
                                    

                                    Above call create Split Window. CMyTabClass is derived from CTabView. So, by default the split window should contain tab splitter at the bottom of the window. Am i right? Because this is how it working in my sample application. In sample i created a Class which derives from CTabView and the window is created with tab splitter in the bottom by default. Later i started adding view using addview(). Then why in my application, splitter is not visible in bottom of the splitter window? why should i explicitly create it using Create()..?

                                    _ 1 Reply Last reply
                                    0
                                    • S Sampath579

                                      Please correct me if i am wrong. While creating a Split window using below statement.

                                      bStatus = GetSplitterObj()->CreateView
                                      			(
                                      				1,
                                      				1,
                                      				RUNTIME\_CLASS(CMyTabClass),
                                      				sizeView,
                                      				pContext
                                      			);
                                      

                                      Above call create Split Window. CMyTabClass is derived from CTabView. So, by default the split window should contain tab splitter at the bottom of the window. Am i right? Because this is how it working in my sample application. In sample i created a Class which derives from CTabView and the window is created with tab splitter in the bottom by default. Later i started adding view using addview(). Then why in my application, splitter is not visible in bottom of the splitter window? why should i explicitly create it using Create()..?

                                      _ Offline
                                      _ Offline
                                      _Flaviu
                                      wrote on last edited by
                                      #20

                                      The code:

                                      bStatus = GetSplitterObj()->CreateView
                                      (
                                      1,
                                      1,
                                      RUNTIME_CLASS(CMyTabClass),
                                      sizeView,
                                      pContext
                                      );

                                      it is only put CMyTabClass view into your splitter window. The creation of the tabs inside this CMyTabClass should be done in CMyTabClass::OnCreate, where AddView(...) calling is mandatory. So, you should add at least one tab in order to see something inside your splitter window :)

                                      S 1 Reply Last reply
                                      0
                                      • _ _Flaviu

                                        The code:

                                        bStatus = GetSplitterObj()->CreateView
                                        (
                                        1,
                                        1,
                                        RUNTIME_CLASS(CMyTabClass),
                                        sizeView,
                                        pContext
                                        );

                                        it is only put CMyTabClass view into your splitter window. The creation of the tabs inside this CMyTabClass should be done in CMyTabClass::OnCreate, where AddView(...) calling is mandatory. So, you should add at least one tab in order to see something inside your splitter window :)

                                        S Offline
                                        S Offline
                                        Sampath579
                                        wrote on last edited by
                                        #21

                                        Then how come in sample application, below code itself creating a tab bar (horizontal with arrow buttons) in window?

                                        if (CTabView::OnCreate(lpCreateStruct) == -1)
                                        return -1;

                                        The same above piece of code in my application not creating that horizontal tab bar unless i create MFCTabCtl tab; tab.create()....

                                        1 Reply Last reply
                                        0
                                        • _ _Flaviu

                                          First of all, create an CTabbedView derived from CTabView.

                                          class CTabbedView : public CTabView
                                          {
                                          protected: // create from serialization only
                                          CTabbedView();
                                          DECLARE_DYNCREATE(CTabbedView)
                                          ...
                                          };

                                          Then, in OnCreate:

                                          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:

                                          if(! m\_wndSplitterTab.CreateView(1, 0, RUNTIME\_CLASS(CTabbedView), CSize(0, 0), pContext))
                                          {
                                          	m\_wndSplitterTab.DestroyWindow();
                                          	return FALSE;
                                          }
                                          

                                          Tell me if is not clear.

                                          S Offline
                                          S Offline
                                          Sampath579
                                          wrote on last edited by
                                          #22

                                          In above provided sample code, i have some doubts. When i created a class CTabbedView which is inherited from CTabView, in OnCreate(), the below call it self created a tab control (horizontal splitter) without any tabs.

                                          if (CTabView::OnCreate(lpCreateStruct) == -1)
                                          return -1;

                                          Then what is the use of below call?

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

                                          What is the exact difference between AddTab and AddView.?

                                          _ 1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups