views:

616

answers:

2

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 ?

Thanks all.

+1  A: 

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.

Shane MacLaughlin
I tried that but MFC raises an exception when DeleteView is called.
Konrad
That means you're doing some other overlapping thing wrong. Did you think it was MFC doing something wrong?Based on this and some of your other questions it seems like you need to learn some MFC basics. Programming Windows with MFC is a great book.
Aidan Ryan
A: 

Does this help?

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

I have used something very similar myself,

Rob
I can't seem to get that code to work, it keeps failing. I think it is to do with the fact that the splitter I am using it on is a child in another splitter. Plus I really wanted to write / implement it myself rather than taking a copyrighted piece of work and duck-taping it to my project.
Konrad