Nested splitter question - Programmer

This is a discussion on Nested splitter question - Programmer ; Hello, I'm having a funny problem with a nested splitter. I'm trying to get three windows like this: +-----------------------+ | | | +-----------------------+ | | +-----------------------+ The code I have works fine, if I have the nested splitter in the ...

+ Reply to Thread
Results 1 to 3 of 3

Thread: Nested splitter question

  1. Nested splitter question

    Hello,

    I'm having a funny problem with a nested splitter. I'm trying to get
    three windows like this:

    +-----------------------+
    | | |
    +-----------------------+
    | |
    +-----------------------+

    The code I have works fine, if I have the nested splitter in the bottom
    row. But if I do it with the nested splitter in the top row, the
    nested splitter almost disappears at the top of the screen, and the
    bottom pane fills the screen.

    Can anyone tell me what I am doing wrong?

    TIA,

    Roger Pearse
    --------------------------------



    BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/,
    CCreateContext* pContext)
    {
    /* return m_wndMainSplitter.Create(this,
    2, 2, // TODO: adjust the number of rows, columns
    CSize(10, 10), // TODO: adjust the minimum pane size
    pContext);*/

    //-- Start of nested splitter code

    // Create a splitter with 2 rows and 1 column
    if (!m_wndMainSplitter.CreateStatic(this, 2, 1)) {
    TRACE("Failed to CreateStaticSplitter\n");
    return FALSE;
    }


    // Add the lower splitter pane - which is a nested splitter with 2
    rows -- in row 1, col 0
    if (!m_wndNestedSplitter.CreateStatic(
    &m_wndMainSplitter, // our parent window is the first splitter
    1, 2, // the new splitter is 1 rows, 2 column
    WS_CHILD | WS_VISIBLE | WS_BORDER, // style, WS_BORDER is needed
    m_wndMainSplitter.IdFromRowCol(0, 0)
    // New splitter is in the first row, 1st column of first splitter
    )) {
    TRACE0("Failed to create nested splitter\n");
    return FALSE;
    }

    // Now create the two views inside the nested splitter
    if (!m_wndNestedSplitter.CreateView(0, 0, RUNTIME_CLASS(CMyView),
    CSize(400, 200), pContext)) {
    TRACE("Failed to create left view pane\n");
    return FALSE;
    }

    if (!m_wndNestedSplitter.CreateView(0, 1, RUNTIME_CLASS(CMyView),
    CSize(200, 200), pContext)) {
    TRACE("Failed to create right view pane\n");
    return FALSE;
    }
    /**/

    // Create a pane in row 1, col 0
    if (!m_wndMainSplitter.CreateView(1, 0, RUNTIME_CLASS(CMyView),
    CSize(200, 400), pContext)) {
    TRACE("Failed to create bottom view pane\n");
    return FALSE;
    }

    //-- End of nested splitter code

    // m_wndMainSplitter.SetActivePane(0,0);
    return TRUE;

    }


  2. Re: Nested splitter question

    roger_pearse@yahoo.co.uk wrote:

    > Hello,
    >
    > I'm having a funny problem with a nested splitter. I'm trying to get
    > three windows like this:
    >
    > +-----------------------+
    > | | |
    > +-----------------------+
    > | |
    > +-----------------------+
    >
    > The code I have works fine, if I have the nested splitter in the bottom
    > row. But if I do it with the nested splitter in the top row, the
    > nested splitter almost disappears at the top of the screen, and the
    > bottom pane fills the screen.
    >
    > Can anyone tell me what I am doing wrong?


    The CRect arguments passed to CreateStatic and CreateView are mostly
    ignored by the splitter resizing code. After you get everything created
    (which it sounds like is OK) use the splitter GetRowInfo/SetRowInfo and
    RecalcLayout to really set the sizes. This is usually done in the frame
    window OnSize message handler so you can resize the panes to your liking
    when the frame window is resized. Note that you need the GetSafeHwnd()
    like this...

    void CMainFrame::OnSize(UINT nType, int cx, int cy)
    {
    if (m_wndSplitter.GetSafeHwnd())
    {
    // Keep the right pane at fixed width
    int cxCur0, cxCur1, cxMin0, cxMin1;
    m_wndSplitter.GetColumnInfo(0, cxCur0, cxMin0);
    m_wndSplitter.GetColumnInfo(1, cxCur1, cxMin1);
    int tot = cxCur0 + cxCur1;
    cxCur0 = max(tot - m_RightPaneWidth, 0);
    cxCur1 = m_RightPaneWidth;
    m_wndSplitter.SetColumnInfo(0, cxCur0, cxMin0);
    m_wndSplitter.SetColumnInfo(1, cxCur1, cxMin1);
    m_wndSplitter.RecalcLayout();
    }
    CFrameWnd::OnSize(nType, cx, cy);
    }


    --
    Scott McPhillips [VC++ MVP]


  3. Re: Nested splitter question

    Scott McPhillips [MVP] wrote:
    > roger_pearse@yahoo.co.uk wrote:
    >
    > > Hello,
    > >
    > > I'm having a funny problem with a nested splitter. I'm trying to

    get
    > > three windows like this:
    > >
    > > +-----------------------+
    > > | | |
    > > +-----------------------+
    > > | |
    > > +-----------------------+
    > >
    > > The code I have works fine, if I have the nested splitter in the

    bottom
    > > row. But if I do it with the nested splitter in the top row, the
    > > nested splitter almost disappears at the top of the screen, and the
    > > bottom pane fills the screen.
    > >
    > > Can anyone tell me what I am doing wrong?

    >
    > The CRect arguments passed to CreateStatic and CreateView are mostly
    > ignored by the splitter resizing code. After you get everything

    created
    > (which it sounds like is OK) use the splitter GetRowInfo/SetRowInfo

    and
    > RecalcLayout to really set the sizes. This is usually done in the

    frame
    > window OnSize message handler so you can resize the panes to your

    liking
    > when the frame window is resized. Note that you need the

    GetSafeHwnd()
    > like this...
    >
    > void CMainFrame::OnSize(UINT nType, int cx, int cy)
    > {
    > if (m_wndSplitter.GetSafeHwnd())
    > {
    > // Keep the right pane at fixed width
    > int cxCur0, cxCur1, cxMin0, cxMin1;
    > m_wndSplitter.GetColumnInfo(0, cxCur0, cxMin0);
    > m_wndSplitter.GetColumnInfo(1, cxCur1, cxMin1);
    > int tot = cxCur0 + cxCur1;
    > cxCur0 = max(tot - m_RightPaneWidth, 0);
    > cxCur1 = m_RightPaneWidth;
    > m_wndSplitter.SetColumnInfo(0, cxCur0, cxMin0);
    > m_wndSplitter.SetColumnInfo(1, cxCur1, cxMin1);
    > m_wndSplitter.RecalcLayout();
    > }
    > CFrameWnd::OnSize(nType, cx, cy);
    > }


    Many thanks indeed. Yes, everything is created OK as far as I can
    tell. I'll try this out.

    Roger Pearse


+ Reply to Thread