Search code examples
c++mfcviewsplitter

Splitting a already split pane (MFC)


In my MFC program I am using a splitter to create two panes. I now want to split one of these panes in half again and put in another view, can someone talk me through how to do it or point me in the direction of some code?

I would prefer to code it myself so I am not interested in custom derived classes unless they are extremely basic.

Thanks!


Solution

  • In CMainFrame::OnCreateClient

    // Create splitter with 2 rows and 1 col
    m_wndSplitter.CreateStatic(this, 2, 1);
    // Create a view in the top row
    m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CView1), CSize(100, 100), pContext);
    // Create a 2 column splitter that will go in the bottom row of the first
    m_wndSplitter2.CreateStatic(&m_wndSplitter, 1, 2, WS_CHILD|WS_VISIBLE, m_wndSplitter.IdFromRowCol(1, 0));
    // Create views for the bottom splitter
    m_wndSplitter2.CreateView(0, 0, RUNTIME_CLASS(CView2), CSize(100, 100), pContext); 
    m_wndSplitter2.CreateView(0, 1, RUNTIME_CLASS(CView3), CSize(100, 100), pContext);
    ...