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 create 2 splitters in a window (using MFC)

how to create 2 splitters in a window (using MFC)

Scheduled Pinned Locked Moved C / C++ / MFC
c++csharpvisual-studiodata-structurestutorial
5 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.
  • T Offline
    T Offline
    Trucker
    wrote on last edited by
    #1

    Hello, I am a newbie to MFC programming in VC++. I can't seem to create more than one splitter in my MFC application.:omg: I need to create a window similar to windows explorer but on the right I want 2 panes not 1. So instead of the right pane I want 2 horizontal panes (one on top of the other). Ultimately what I want to do is: 1)display a directory tree in the left pane 2)display files and/or directories (of selected directory from tree) in the right-top pane. 3)display contents of selected file (from above pane) in right-bottom pane. So I can get the first vertical splitter - Visual Studio actually makes it for me cause in the application creation wizard, under visual interface features, for toolbars i selected "standard docking" with "browser style". But I can't seem to add another one. I would appreciate if anyone could tell me how to code for this second splitter and where to code this (what class and function). TraileR ParK LifE 4Ever >:{

    G 1 Reply Last reply
    0
    • T Trucker

      Hello, I am a newbie to MFC programming in VC++. I can't seem to create more than one splitter in my MFC application.:omg: I need to create a window similar to windows explorer but on the right I want 2 panes not 1. So instead of the right pane I want 2 horizontal panes (one on top of the other). Ultimately what I want to do is: 1)display a directory tree in the left pane 2)display files and/or directories (of selected directory from tree) in the right-top pane. 3)display contents of selected file (from above pane) in right-bottom pane. So I can get the first vertical splitter - Visual Studio actually makes it for me cause in the application creation wizard, under visual interface features, for toolbars i selected "standard docking" with "browser style". But I can't seem to add another one. I would appreciate if anyone could tell me how to code for this second splitter and where to code this (what class and function). TraileR ParK LifE 4Ever >:{

      G Offline
      G Offline
      GKarRacer
      wrote on last edited by
      #2

      Add another CSplitterWnd variable to your CMainFrame class, e.g. m_RightSplitter. Replace CMainFrame::OnCreateClient with code similar to:

      // create splitter window
      if (!m_wndSplitter.CreateStatic(this, 1, 2))
      {
      m_wndSplitter.DestroyWindow();
      return FALSE;
      }

      if( ! m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) )
      return(FALSE);
      m_RightSplitter.CreateStatic( &m_wndSplitter, 2, 1, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0,1) );
      if( ! m_RightSplitter.CreateView(0, 0, RUNTIME_CLASS(CTopRightView), CSize(100, 100), pContext) ||
      ! m_RightSplitter.CreateView(1, 0, RUNTIME_CLASS(CBottomRightView), CSize(100, 100), pContext) )
      {
      return(FALSE);
      }

      T 1 Reply Last reply
      0
      • G GKarRacer

        Add another CSplitterWnd variable to your CMainFrame class, e.g. m_RightSplitter. Replace CMainFrame::OnCreateClient with code similar to:

        // create splitter window
        if (!m_wndSplitter.CreateStatic(this, 1, 2))
        {
        m_wndSplitter.DestroyWindow();
        return FALSE;
        }

        if( ! m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(100, 100), pContext) )
        return(FALSE);
        m_RightSplitter.CreateStatic( &m_wndSplitter, 2, 1, WS_CHILD | WS_VISIBLE, m_wndSplitter.IdFromRowCol(0,1) );
        if( ! m_RightSplitter.CreateView(0, 0, RUNTIME_CLASS(CTopRightView), CSize(100, 100), pContext) ||
        ! m_RightSplitter.CreateView(1, 0, RUNTIME_CLASS(CBottomRightView), CSize(100, 100), pContext) )
        {
        return(FALSE);
        }

        T Offline
        T Offline
        Trucker
        wrote on last edited by
        #3

        Hi Bill, Thanks for the reply. When I try your code I get these errors : error: C2039: 'classCTopRightView': is not a member of 'CTopRightView' error: C2065: 'classCTopRightView': undeclared identifier <> I added CTopRightView and CBottomRightView as 'Generic C++ classes' (did not code them though - dont know how:sigh: ). I have no idea why its adding the word 'class' in front of the 2 class names.:confused: TraileR ParK LifE 4Ever >:{

        G 1 Reply Last reply
        0
        • T Trucker

          Hi Bill, Thanks for the reply. When I try your code I get these errors : error: C2039: 'classCTopRightView': is not a member of 'CTopRightView' error: C2065: 'classCTopRightView': undeclared identifier <> I added CTopRightView and CBottomRightView as 'Generic C++ classes' (did not code them though - dont know how:sigh: ). I have no idea why its adding the word 'class' in front of the 2 class names.:confused: TraileR ParK LifE 4Ever >:{

          G Offline
          G Offline
          GKarRacer
          wrote on last edited by
          #4

          They have to CWnd derived classes - most likely derived from CView. In addition they also have to have DECLARE_DYNCREATE in the class header file and IMPLEMENT_DYNCREATE in the class source file. If you look at the default CView classes created for the project you will see these lines. Use "MFC Class" to create the classes instead and derive them from CView. It will then put these lines in automatically for you. The "classCTopRightView" is a special member variable that MFC puts in for runtime class typing and dynamic creation. It uses the name "classCYOURCLASSNAMEHERE" as the member name. The above macros put these in for you.

          T 1 Reply Last reply
          0
          • G GKarRacer

            They have to CWnd derived classes - most likely derived from CView. In addition they also have to have DECLARE_DYNCREATE in the class header file and IMPLEMENT_DYNCREATE in the class source file. If you look at the default CView classes created for the project you will see these lines. Use "MFC Class" to create the classes instead and derive them from CView. It will then put these lines in automatically for you. The "classCTopRightView" is a special member variable that MFC puts in for runtime class typing and dynamic creation. It uses the name "classCYOURCLASSNAMEHERE" as the member name. The above macros put these in for you.

            T Offline
            T Offline
            Trucker
            wrote on last edited by
            #5

            WOW! It worked!:-D Thanks a lot, really appreciate it... not many people help out on their own time, thanks greatly again!:) TraileR ParK LifE 4Ever >:{

            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