Frame inside a Splitter Pane

Hi there,

I've got an application that is broken into three views. A tree to the left, and a vertically split area to the right. What I want to do is "sometimes" have one of the views on the right split again.

I can change the view of the pane, but the splitter is the problem.

The way I would see to do this would have to be to put a FrameWnd inside the appropriate Splitterwnd pane. Therein lies the problem.

How do I do this? ... or can I place a splittedwnd in a view class.

Thanks for your help...
pdebAsked:
Who is Participating?
 
WBerthinConnect With a Mentor Commented:
Probably the most convenient way to do this is to set up 3 static splitter windows by splitting the second pane. You can
resize the splitter windows programatically and thus move the
third view to the far right when it is not in use. All that
would be visible is a narrow bar.

You can also put Frame window in split windows. This works fine
if you want to put other things in the split windows such as
Control Bars of various types. Since you can split panes it is
not really necessary to put a frame into a split window just
to split the window again it again.

If you want you can split windows dynamically (as opposed to
statically). You can create a dynamic splitter window that
displays diffenent types of view in different panes. Do this by
deriving a class from CSplitterWnd, overriding CreateView, and
calling CSplitterWnd::CreateView with a CRuntimeClass pointer to
the new view. For example if you wanted to dynamically override
the view in row 0, column 1 without affecting the view in row 0
column 0 you could write:

BOOL CDynamicSplitterWnd::CreateView(
    int row, int col, CRuntimeClass* pViewClass,
    sizeInit, pContext )
{
    if( col == 1 )
    {
        return CSplitterWnd::CreateView(row, col,
           RUNTIME_CLASS(CMyNewView), sizeInit, pContext );
    }
    return CSplitterWnd::CreateView(row, col,
       pViewClass, sizeInit, pContext );
}

You cannot of course split a CView, but if you can change the
view (I assume meaning window area) to a pane you can then split
the pane dynamically as above.

SAMPLE CODE
As a futher example of working with splitters, the following
code is taken from a program that creates 3 static splitter
windows, and puts a CFrameWnd in each:

BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
      // Create a static splitter with 1 row, 2 columns
      if( !m_FormatSplitter.CreateStatic(
            this,                  // CWnd* pParentWnd
            1,                  // int nRows
            2,                  // int nColumns
            WS_CHILD | WS_VISIBLE,      // DWORD dwStyle
            AFX_IDW_PANE_FIRST ) )      // UINT nID      
            return FALSE;

      // Add the second splitter frame in column 1
      // which is a nested splitter with 2 columns
      if( !m_DatabaseSplitter.CreateStatic(
            &m_FormatSplitter,      // CWnd* pParentWnd - our
                                        // parent window is the
                                        // first splitter
            1,                    // int nRows
            2,                  // int nColumns
            WS_CHILD | WS_VISIBLE ,      // DWORD dwStyle
            m_FormatSplitter.IdFromRowCol(0, 0) ) )
                       // UINT nID - the new splitter is in the
                       // 1st row and 1st column of the first
                       // splitter
            return FALSE;

      if( !m_FormatSplitter.CreateView(
            0,               // int nRow
            1,            // int nColumn
            RUNTIME_CLASS(CTemplateFrm),
                         // CRuntimeClass* pViewClass
            CSize( 0 , 0 ),       // Size sizeInit
            pContext) )      // CCreateContext* pContext
            return FALSE;

      // Set the Database pane in the left frame
      if( !m_DatabaseSplitter.CreateView(
            0,       // int nRow
            0,      // int nColumn
            RUNTIME_CLASS(CMainTreeFrm),
                      // CRuntimeClass* pViewClass
            CSize( m_nDatabaseWidth , 0 ),// CSize sizeInit
            pContext ) )      // CCreateContext* pContext
            return FALSE;

      // Set the search result pane in the center frame
      if( !m_DatabaseSplitter.CreateView(
            0,      // int nRow
            1,      // int nColumn                              RUNTIME_CLASS(CSearchResultFrm),
                       // CRuntimeClass* pViewClass
            CSize( 0 , 0 ),       // CSize sizeInit
            pContext) )  // CCreateContext* pContext
            return FALSE;

      // Set the column width of the database pane
      m_FormatSplitter.SetColumnInfo(
                0, m_nSearchResultWidth,0);
}

0
 
pdebAuthor Commented:
I didn't want to have three splitters in the main frame because I have 4 views that want to go in that pane, and only one wants the splitter.

The best way I found was to place a frame in pane and then split that - so it would only appear in that view.

Your answer was good and comprehensive.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.