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. Splitter Window

Splitter Window

Scheduled Pinned Locked Moved C / C++ / MFC
4 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.
  • M Offline
    M Offline
    Mahendra_786
    wrote on last edited by
    #1

    I am creating a 2x2 spllitter window in a SDI application. // OnCreateClient of SDI Frame Window ... VERIFY(m_wndSplitter.CreateStatic(this, m_rows, m_cols)); ... I want every pane to be of the same size (plus-minus 1 pixel). In OnSize I do something like: // OnSize of Frame Window ... m_wndSplitter.GetClientRect(rect); int row_height = rect.Height(); int col_width = rect.Width(); row_height /= 2; col_width /= 2; m_wndSplitter.SetRowInfo(0, row_height, 100); m_wndSplitter.SetRowInfo(1, row_height, 100); m_wndSplitter.SetColumnInfo(0, col_width, 100); m_wndSplitter.SetColumnInfo(1, col_width, 100); m_wndSplitter.RecalcLayout(); ... HOWEVER probably due to the "splitting margin" or border between panes, the pane(0, 0) is larger than the other panes with a difference of about 11 pixels in size. Other than "manually" accounting for the border thickness, is there a better way of making the panes same size. Thanks in anticipation.

    I 1 Reply Last reply
    0
    • M Mahendra_786

      I am creating a 2x2 spllitter window in a SDI application. // OnCreateClient of SDI Frame Window ... VERIFY(m_wndSplitter.CreateStatic(this, m_rows, m_cols)); ... I want every pane to be of the same size (plus-minus 1 pixel). In OnSize I do something like: // OnSize of Frame Window ... m_wndSplitter.GetClientRect(rect); int row_height = rect.Height(); int col_width = rect.Width(); row_height /= 2; col_width /= 2; m_wndSplitter.SetRowInfo(0, row_height, 100); m_wndSplitter.SetRowInfo(1, row_height, 100); m_wndSplitter.SetColumnInfo(0, col_width, 100); m_wndSplitter.SetColumnInfo(1, col_width, 100); m_wndSplitter.RecalcLayout(); ... HOWEVER probably due to the "splitting margin" or border between panes, the pane(0, 0) is larger than the other panes with a difference of about 11 pixels in size. Other than "manually" accounting for the border thickness, is there a better way of making the panes same size. Thanks in anticipation.

      I Offline
      I Offline
      Iain Clarke Warrior Programmer
      wrote on last edited by
      #2

      There is no way for a frame to get its splitters internal dimensions. But you could write a new class inheriting from CSplitterWnd, and use that instead... Be warned, this not debugged (or even compiled code), so check it out yourself. If omitted *loads* of error checks.

      class CSymetricalSplitter : public CSplitterWnd
      {
      public:
      BOOL ArrangeSymmetrically (int nMinX, int nMinY)
      {
      CRect rcClient;
      GetClientRect (&rcClient);
      int nCols, nRows, nSize, n;
      nCols = GetColumnCount ();
      nRows = GetRowCount ();
      if (!nRows || !nCount)
      return FALSE;

          // Rows
          nSize = rcClient.Height ();
          nSize -= (nRows - 1) \* m\_cySplitterGap; // <-- A protected variable
          nSize /= nRows;
          for (n = 0; n < nRows; n++)
              SetRowInfo (n, nSize, nMinY); 
      
      
          // Columns
          ....
      
          RecalcLayout ();
      }
      

      };

      Hopefully that should help! Iain.

      M 1 Reply Last reply
      0
      • I Iain Clarke Warrior Programmer

        There is no way for a frame to get its splitters internal dimensions. But you could write a new class inheriting from CSplitterWnd, and use that instead... Be warned, this not debugged (or even compiled code), so check it out yourself. If omitted *loads* of error checks.

        class CSymetricalSplitter : public CSplitterWnd
        {
        public:
        BOOL ArrangeSymmetrically (int nMinX, int nMinY)
        {
        CRect rcClient;
        GetClientRect (&rcClient);
        int nCols, nRows, nSize, n;
        nCols = GetColumnCount ();
        nRows = GetRowCount ();
        if (!nRows || !nCount)
        return FALSE;

            // Rows
            nSize = rcClient.Height ();
            nSize -= (nRows - 1) \* m\_cySplitterGap; // <-- A protected variable
            nSize /= nRows;
            for (n = 0; n < nRows; n++)
                SetRowInfo (n, nSize, nMinY); 
        
        
            // Columns
            ....
        
            RecalcLayout ();
        }
        

        };

        Hopefully that should help! Iain.

        M Offline
        M Offline
        Mahendra_786
        wrote on last edited by
        #3

        Thanks. This is probably the only way out. Here is a fragment from Q & A: C++ (Periodicals 1998) from MSDN Library 1999 that does something similar: After calculating the heights of the toolbars, the next troublesome task is calculating the height and width of all the splitter window components: the border with which it surrounds each pane and the splitter bar itself. All these magic numbers are contained within data members in CSplitterWnd, but naturally the data is protected, which means you can’t access it! Sigh. So what do you do? Simple: just derive a new class with public functions to export the protected data, and use it instead of CSplitterWnd in your main frame. class CMySplitterWnd : public CSplitterWnd { public: CSize GetBorderSize() { return CSize(m_cxBorder,m_cyBorder); } CSize GetSplitterSize() { return CSize(m_cxSplitter,m_cySplitter); } };

        M 1 Reply Last reply
        0
        • M Mahendra_786

          Thanks. This is probably the only way out. Here is a fragment from Q & A: C++ (Periodicals 1998) from MSDN Library 1999 that does something similar: After calculating the heights of the toolbars, the next troublesome task is calculating the height and width of all the splitter window components: the border with which it surrounds each pane and the splitter bar itself. All these magic numbers are contained within data members in CSplitterWnd, but naturally the data is protected, which means you can’t access it! Sigh. So what do you do? Simple: just derive a new class with public functions to export the protected data, and use it instead of CSplitterWnd in your main frame. class CMySplitterWnd : public CSplitterWnd { public: CSize GetBorderSize() { return CSize(m_cxBorder,m_cyBorder); } CSize GetSplitterSize() { return CSize(m_cxSplitter,m_cySplitter); } };

          M Offline
          M Offline
          Mahendra_786
          wrote on last edited by
          #4

          (To be complete) this is what can be done: CRect rect; m_wndSplitter.GetClientRect(rect); CSize splitter_size = m_wndSplitter.GetSplitterSize(); CSize border_size = m_wndSplitter.GetBorderSize(); int row_height = rect.Height() - ((splitter_size.cy * (m_rows - 1)) + (border_size.cy * 2)); int col_width = rect.Width() - ((splitter_size.cx * (m_cols - 1)) + (border_size.cx * 2)); row_height /= m_rows; col_width /= m_cols; for (int i = 0; i < m_rows; i++) { m_wndSplitter.SetRowInfo(i, row_height, 100); } for (int j = 0; j < m_cols; j++) { m_wndSplitter.SetColumnInfo(j, col_width, 100); } m_wndSplitter.RecalcLayout(); Regards Mahendra

          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