how to add show/hide Cviews?

Hi,
i have 4 views in splitterpanes in one window..and other views are in otherwindows.how to show/hide by clicking toolbarbuttons?
CView* CMainFrame::SelectView(UINT nViewID)
{


      CView* pNewView = ((CTresManApp*)AfxGetApp())->GetView(nViewID);

      if(pNewView)
      {
            SwitchToView(pNewView);      
      }
      
      
      return pNewView;

}
CView* CMainFrame::SwitchToView(CView *pNewView)
{
      CView* pOldActiveView = GetActiveView();
//      CView* pOldActiveView = ((CTresManApp*)AfxGetApp())->GetView(1);


      CDocument* pActiveDocument = GetActiveDocument();

      ASSERT(pOldActiveView != NULL);
      ASSERT(pActiveDocument != NULL);
      ASSERT_VALID(pOldActiveView);
      ASSERT(pOldActiveView->GetDocument() == pActiveDocument);

      if (pNewView != pOldActiveView)
      {
            
            // Show the newly active view and hide the inactive view.
                  
                  pNewView->ShowWindow(SW_SHOW);  
                  pOldActiveView->ShowWindow(SW_HIDE);
                  SetActiveView(pNewView);

      }
      return pOldActiveView;

}
presently i have activeview it enables by clicking respective toolbar buttons but i want to show all 4 views in one window by clicking one toolbar button.
is it possible to activate morethan 1 view at a time?..
srikadiAsked:
Who is Participating?
 
alb66Connect With a Mentor Commented:
In order to hide/show a view you must show/hide its frame window:

pNewView->GetParentFrame()->ShowWindow(SW_SHOW);  
pOldActiveView->GetParentFrame()->ShowWindow(SW_HIDE);
0
 
ZoppoConnect With a Mentor Commented:
Hi,

@alb66: this doesn't work for splitter windows.

I think you'll have to delete the view to hide and create a new view to show - you can find a sample code at http://www.codeguru.com/cpp/w-d/splitter/article.php/c1533/ - there's a function 'CMainFrame::OnView1' which demonstrates this.

Hope that helps,

ZOPPO
0
 
alb66Commented:
Yes, my code show/hide all the views in the splitter window. May be I misunderstood the question.
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.