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. MFC questions

MFC questions

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++
9 Posts 3 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.
  • B Offline
    B Offline
    Binayak
    wrote on last edited by
    #1

    Hi, 1. I have put a TabControl inside a formview in the MFC-SDI application. If I resize the window I want the tab control to always fit in the window (that means if I make the window bigger the control inside will become bigger and if I make the window smaller I want the control to get smaller). Please advise how I can do that? 2. How can I make a SDI application non-resizable? Thanks,

    R 1 Reply Last reply
    0
    • B Binayak

      Hi, 1. I have put a TabControl inside a formview in the MFC-SDI application. If I resize the window I want the tab control to always fit in the window (that means if I make the window bigger the control inside will become bigger and if I make the window smaller I want the control to get smaller). Please advise how I can do that? 2. How can I make a SDI application non-resizable? Thanks,

      R Offline
      R Offline
      Ravi Bhavnani
      wrote on last edited by
      #2

      Add a WM_SIZE handler in your view class. In it, do the following:

      CRect rectView;
      GetClientRect (&rectView);
      m_tabCtrl.MoveWindow (&rectView);

      This will cause the tab control to fill the view's client area. /ravi My new year resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

      B 1 Reply Last reply
      0
      • R Ravi Bhavnani

        Add a WM_SIZE handler in your view class. In it, do the following:

        CRect rectView;
        GetClientRect (&rectView);
        m_tabCtrl.MoveWindow (&rectView);

        This will cause the tab control to fill the view's client area. /ravi My new year resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

        B Offline
        B Offline
        Binayak
        wrote on last edited by
        #3

        I used following code Onsize but I'm getting asserting error at line 279 of winocc.cpp CFormView::OnSize(nType, cx, cy); CRect rectView; GetClientRect (&rectView); m_TabCtrl.MoveWindow (&rectView);

        R 1 Reply Last reply
        0
        • B Binayak

          I used following code Onsize but I'm getting asserting error at line 279 of winocc.cpp CFormView::OnSize(nType, cx, cy); CRect rectView; GetClientRect (&rectView); m_TabCtrl.MoveWindow (&rectView);

          R Offline
          R Offline
          Ravi Bhavnani
          wrote on last edited by
          #4

          Perhaps you haven't linked m_tabCtrl to the tab control in the dialog template? Put this line before the call to MoveWindow():

          ASSERT (m_tabCtrl.GetSafeHwnd() != NULL);

          to ensure that m_tabCtrl has been properly created before you try to resize it. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

          B 1 Reply Last reply
          0
          • R Ravi Bhavnani

            Perhaps you haven't linked m_tabCtrl to the tab control in the dialog template? Put this line before the call to MoveWindow():

            ASSERT (m_tabCtrl.GetSafeHwnd() != NULL);

            to ensure that m_tabCtrl has been properly created before you try to resize it. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

            B Offline
            B Offline
            Binayak
            wrote on last edited by
            #5

            It worked. Thanks.... I have another similar question :-) I have two tree controls attached to the tabs in the tab control. To fit the tree control in the tab control what should I do? 'cause I can't write the wm_size handler for the tabcontrol as I'm adding the tree controls in the formview, not in the tabcontrol class.

            R R 2 Replies Last reply
            0
            • B Binayak

              It worked. Thanks.... I have another similar question :-) I have two tree controls attached to the tabs in the tab control. To fit the tree control in the tab control what should I do? 'cause I can't write the wm_size handler for the tabcontrol as I'm adding the tree controls in the formview, not in the tabcontrol class.

              R Offline
              R Offline
              Ravi Bhavnani
              wrote on last edited by
              #6

              I think you might be confusing a CTabCtrl with a CPropertySheet. A CTabCtrl doesn't "contain" child dialogs or controls - all it does is allow the user to select a tab. A tab control's parent receives notifications when the current tab selection changes. That being said, what you probably want to do (to mimic the behavior of a CPropertySheet) is to create a bunch of child controls/dialogs (whose common parent is your view), one of which is displayed in response to the change in the currently selected tab. You'll also need to check the "Transparent" attribute of the tab control so that it doesn't hide the child controls/dialogs. The appropriate control/dialog is displayed in response to a change in the currently selected tab in the following manner:

              // First hide all controls
              CWnd* pDisplayedWnd = NULL;
              m_treeCtrl_1.ShowWindow (SW_HIDE);
              m_treeCtrl_2.ShowWindow (SW_HIDE);

              // Next, determine which one should be shown
              int nCurTab = m_tabCtrl.GetCurSel();
              switch (nCurTab) {
              case 0:
              pDisplayedWnd = &m_treeCtrl_1;
              break;
              case 1:
              pDisplayedWnd = &m_treeCtrl_2;
              break;
              default:
              // Did you forget to support a tab?
              ASSERT (FALSE);
              break;
              }
              ASSERT (pDisplayedWnd != NULL);

              // Display the control
              pDisplayedWnd->BringWindowToTop();
              pDisplayedWnd->ShowWindow (SW_SHOW);
              pDisplayedWnd->Invalidate();
              pDisplayedWnd->UpdateWindow();
              pDisplayedWnd->BringWindowToTop();
              pDisplayedWnd->SetFocus();

              If this is too much work, you might want to consider using a CPropertySheet. See the examples at CP if you need help. /ravi My new year's resolution: 2048 x 1536 Home | Articles | Freeware | Music ravib@ravib.com

              1 Reply Last reply
              0
              • B Binayak

                It worked. Thanks.... I have another similar question :-) I have two tree controls attached to the tabs in the tab control. To fit the tree control in the tab control what should I do? 'cause I can't write the wm_size handler for the tabcontrol as I'm adding the tree controls in the formview, not in the tabcontrol class.

                R Offline
                R Offline
                Roger Allen
                wrote on last edited by
                #7

                Don't forget to call SetScaleToFitSize(cx, cy) at he end of your OnSize() procedure otherwise you will get scroll bars shown if the client rectangle size is smaller than the size of the dialog template used to create the form view from. Roger Allen - Sonork 100.10016 Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...

                B 2 Replies Last reply
                0
                • R Roger Allen

                  Don't forget to call SetScaleToFitSize(cx, cy) at he end of your OnSize() procedure otherwise you will get scroll bars shown if the client rectangle size is smaller than the size of the dialog template used to create the form view from. Roger Allen - Sonork 100.10016 Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...

                  B Offline
                  B Offline
                  Binayak
                  wrote on last edited by
                  #8

                  I'm using a formview here, setscaletofitsize() is for the scrollview. can you please tell me how I can use it for the scroller in the formview?

                  1 Reply Last reply
                  0
                  • R Roger Allen

                    Don't forget to call SetScaleToFitSize(cx, cy) at he end of your OnSize() procedure otherwise you will get scroll bars shown if the client rectangle size is smaller than the size of the dialog template used to create the form view from. Roger Allen - Sonork 100.10016 Roger Wright: Remember to buckle up, please, and encourage your friends to do the same. It's not just about saving your life, but saving the quality of life for those you may leave behind...

                    B Offline
                    B Offline
                    Binayak
                    wrote on last edited by
                    #9

                    worked SIZE sizeTotal; sizeTotal.cx= cx; sizeTotal.cy= cy; CScrollView::SetScaleToFitSize( sizeTotal);

                    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