[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 379
  • Last Modified:

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?..
0
srikadi
Asked:
srikadi
  • 2
2 Solutions
 
alb66Commented:
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
 
ZoppoCommented:
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

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now