MFC: Showing / Hiding Splitter Panes

4.4k Views Asked by At

In my application I have a number of panes from m_wndspliter classes. What I want to do is at run time show and hide one of these panes. Whilst with the following code I can show and hide the view associated with the pane, I can't temporarily remove the pane itself.

CWnd * pCurView = m_wndSplitter2.GetPane(2, 0);
if( !pCurView == NULL )
{
    if( fShow )
    {
        pCurView->ShowWindow(SW_SHOW);
        RecalcLayout();
    }
    else
    {
        pCurView->ShowWindow(SW_HIDE);
        RecalcLayout();
    }
}

Any examples / ideas ?

3

There are 3 best solutions below

1
On BEST ANSWER

Does this help?

http://www.codeguru.com/cpp/w-d/splitter/article.php/c1543

I have used something very similar myself,

0
On

Only the CExtSplitter class from the CodeProject article https://www.codeproject.com/Articles/2707/A-Static-Splitter-with-the-Ability-to-Hide-Show-Mu worked for me.

This is still VC6 code but it worked with minor adaptions.

2
On

You need to call CSplitterWnd::DeleteView to do this, which basically means that you have to save your CView elsewhere if you intend to restore it. Usually this is not a problem as all data should be stored in the CDocument rather than CView, but in practice this may not be the case.

The way I have handled this in the past is to have a copy constructor for my CView classes so I could easily store them in temporary variables.