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 resize Tab Control??

How to resize Tab Control??

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
6 Posts 2 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.
  • A Offline
    A Offline
    antonio343
    wrote on last edited by
    #1

    I have an application that is based on TabControl (CFormView), but for now, it appears as the dialog box that did, and I would like that it occupy the window into the framework. How can I do it?

    T 1 Reply Last reply
    0
    • A antonio343

      I have an application that is based on TabControl (CFormView), but for now, it appears as the dialog box that did, and I would like that it occupy the window into the framework. How can I do it?

      T Offline
      T Offline
      TheGreatAndPowerfulOz
      wrote on last edited by
      #2

      You'd call the SetWindowPos[^] member function.

      If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
      You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

      A 1 Reply Last reply
      0
      • T TheGreatAndPowerfulOz

        You'd call the SetWindowPos[^] member function.

        If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
        You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

        A Offline
        A Offline
        antonio343
        wrote on last edited by
        #3

        Yes I know. This is the method that resize the tabControl [code] void CMyTabCtrl::SetRectangle() { CRect tabRect, itemRect; int nX, nY, nXc, nYc; GetClientRect(&tabRect); GetItemRect(0, &itemRect); nX=itemRect.left; nY=itemRect.bottom+1; nXc=tabRect.right-itemRect.left-1; nYc=tabRect.bottom-nY-1; m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW); for(int nCount=1; nCount < m_nNumberOfPages; nCount++){ m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW); } } [/code] But I dont know how to get the size of the framework. What parameter I have to change?

        T 2 Replies Last reply
        0
        • A antonio343

          Yes I know. This is the method that resize the tabControl [code] void CMyTabCtrl::SetRectangle() { CRect tabRect, itemRect; int nX, nY, nXc, nYc; GetClientRect(&tabRect); GetItemRect(0, &itemRect); nX=itemRect.left; nY=itemRect.bottom+1; nXc=tabRect.right-itemRect.left-1; nYc=tabRect.bottom-nY-1; m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW); for(int nCount=1; nCount < m_nNumberOfPages; nCount++){ m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW); } } [/code] But I dont know how to get the size of the framework. What parameter I have to change?

          T Offline
          T Offline
          TheGreatAndPowerfulOz
          wrote on last edited by
          #4

          What do you mean "the size of the framework"?

          If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
          You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

          A 1 Reply Last reply
          0
          • T TheGreatAndPowerfulOz

            What do you mean "the size of the framework"?

            If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
            You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

            A Offline
            A Offline
            antonio343
            wrote on last edited by
            #5

            This is my app http://i54.tinypic.com/1e9qtx.png I'd like TabControl take up all the gray space into the windows MyTabExample1

            1 Reply Last reply
            0
            • A antonio343

              Yes I know. This is the method that resize the tabControl [code] void CMyTabCtrl::SetRectangle() { CRect tabRect, itemRect; int nX, nY, nXc, nYc; GetClientRect(&tabRect); GetItemRect(0, &itemRect); nX=itemRect.left; nY=itemRect.bottom+1; nXc=tabRect.right-itemRect.left-1; nYc=tabRect.bottom-nY-1; m_tabPages[0]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_SHOWWINDOW); for(int nCount=1; nCount < m_nNumberOfPages; nCount++){ m_tabPages[nCount]->SetWindowPos(&wndTop, nX, nY, nXc, nYc, SWP_HIDEWINDOW); } } [/code] But I dont know how to get the size of the framework. What parameter I have to change?

              T Offline
              T Offline
              TheGreatAndPowerfulOz
              wrote on last edited by
              #6

              First, you're calling GetClientRect() in the wrong context. GetClientRect() gets "this" windows client rectangle, not the parents'. If you want to get the parents' client rectangle (the framework as you call it), in the context of the child, then call GetParent()->GetClientRect(). The way I would do what you're trying to do is the following: 1. Using the ClassWizard, add a WM_SIZE and WM_CREATE message handler to your View class, or 2. alternatively add ON_WM_SIZE() and ON_WM_CREATE() to your View class's message map and add the following overrides to your View class's header file:

              afx\_msg void OnSize(UINT nType, int cx, int cy);
              afx\_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
              

              4. add the following code (if you used the ClassWizard to add the WM_SIZE and WM_CREATE handlers, then cut and paste the code as appropriate).

              void CMyTabExampleView::OnSize(UINT nType, int cx, int cy)
              {
              CView::OnSize(nType, cx, cy);

              m\_myTabs.MoveWindow(0, 0, cx, cy);
              
              // TODO: Add your message handler code here
              

              }

              int CMyTabExampleView::OnCreate(LPCREATESTRUCT lpCreateStruct)
              {
              if (CView::OnCreate(lpCreateStruct) == -1)
              return -1;

              CRect rect;
              GetClientRect(&rect);
              
              m\_myTabs.Create(0, rect, this, 9999);
              m\_myTabs.ShowWindow(SW\_SHOW);
              
              return 0;
              

              }

              Of course, the style and ID of the "m_myTabs" window needs to be what you need them to be. Adjust accordingly. Hope this helps. Good luck. :-D Call if you need more help.

              If your actions inspire others to dream more, learn more, do more and become more, you are a leader." - John Quincy Adams
              You must accept one of two basic premises: Either we are alone in the universe, or we are not alone in the universe. And either way, the implications are staggering” - Wernher von Braun

              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