rgrand
asked on
Changing view in a static splitterView
I have a 3 way splitter window with this configuration.
| View 2
View1 |---------
| View 3
I create it with CreateStatic().
Thanks to an action on view1, I want to change view2 (from ClistView to CFormView, for example).
Unfortunatly 'from MSDN CSplitterWnd::CreateView ' :
'All panes of a static splitter window must be created before the framework displays the splitter.'
So how can I change it dynamicly?
Thanks for help in advance
| View 2
View1 |---------
| View 3
I create it with CreateStatic().
Thanks to an action on view1, I want to change view2 (from ClistView to CFormView, for example).
Unfortunatly 'from MSDN CSplitterWnd::CreateView ' :
'All panes of a static splitter window must be created before the framework displays the splitter.'
So how can I change it dynamicly?
Thanks for help in advance
You can find a few articles on CodeGuru site http://codeguru.developer.com/splitter/index.shtml
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Hi!
Also you can find some info in the PAQ:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=10201445
Also you can find some info in the PAQ:
https://www.experts-exchange.com/jsp/qShow.jsp?ta=mfc&qid=10201445
1) derive a splitter window class from CSplitterWnd and create a variable of that type in your main frame
2) create the new view:
CRuntimeClass* pView = RUNTIME_CLASS(YourNewViewC lass);
int nView = nSomeViewID;
CView* pNewView = (CView*)pView->CreateObjec t();
if (pNewView)
{
pNewView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault, pParentWnd, nView, pContext);
pNewView->OnInitialUpdate( );
} // end if
3) change to the new view:
UINT CYourSplitterWnd::ChangeVi ew(CView* pNewPaneView, int row, int col, UINT nOldViewID, bool bFirstView)
{
UINT nPaneViewID = IdFromRowCol(row, col);
UINT nNewViewID = pNewPaneView->GetDlgCtrlID ();
if (nNewViewID == 0)
{
return 0;
} // end if
else if (nNewViewID != (UINT) m_nCurrentViewID)
{
m_nCurrentViewID = nNewViewID;
// set new view active and show it...
CFrameWnd* pFrameWnd = GetParentFrame();
pFrameWnd->SetActiveView(p NewPaneVie w);
pNewPaneView->ShowWindow(S W_SHOW);
// get old view, hide it, and remove from the splitter...
CView* pOldPaneView = (CView*)GetDlgItem(nPaneVi ewID);
if (pOldPaneView)
{
pOldPaneView->ShowWindow(S W_HIDE);
pOldPaneView->SetDlgCtrlID (nOldViewI D);
} // end if
// add the new view to the splitter...
if (pNewPaneView->GetParent() != this)
pNewPaneView->SetParent(th is);
pNewPaneView->SetDlgCtrlID (nPaneView ID);
if (!bFirstView)
RecalcLayout();
} // end else
return nNewViewID;
} // end ChangeView()
I belive that's the basics of it...
hope that helps...
2) create the new view:
CRuntimeClass* pView = RUNTIME_CLASS(YourNewViewC
int nView = nSomeViewID;
CView* pNewView = (CView*)pView->CreateObjec
if (pNewView)
{
pNewView->Create(NULL, NULL, 0L, CFrameWnd::rectDefault, pParentWnd, nView, pContext);
pNewView->OnInitialUpdate(
} // end if
3) change to the new view:
UINT CYourSplitterWnd::ChangeVi
{
UINT nPaneViewID = IdFromRowCol(row, col);
UINT nNewViewID = pNewPaneView->GetDlgCtrlID
if (nNewViewID == 0)
{
return 0;
} // end if
else if (nNewViewID != (UINT) m_nCurrentViewID)
{
m_nCurrentViewID = nNewViewID;
// set new view active and show it...
CFrameWnd* pFrameWnd = GetParentFrame();
pFrameWnd->SetActiveView(p
pNewPaneView->ShowWindow(S
// get old view, hide it, and remove from the splitter...
CView* pOldPaneView = (CView*)GetDlgItem(nPaneVi
if (pOldPaneView)
{
pOldPaneView->ShowWindow(S
pOldPaneView->SetDlgCtrlID
} // end if
// add the new view to the splitter...
if (pNewPaneView->GetParent()
pNewPaneView->SetParent(th
pNewPaneView->SetDlgCtrlID
if (!bFirstView)
RecalcLayout();
} // end else
return nNewViewID;
} // end ChangeView()
I belive that's the basics of it...
hope that helps...
Hi,
Have the pointers of the CSplitterWnd and create them and display them. When U want to change it, delete the pointers so that view goes off and display the fresh view with the required change freshly. That should work though it is a work around method.
I had the similar problem, on some action, the requirement was to delete the view2 and show view1 abd view3 only. There I have followed the same way. I still have the sample of it too.
Try it out.
VinExpert
Have the pointers of the CSplitterWnd and create them and display them. When U want to change it, delete the pointers so that view goes off and display the fresh view with the required change freshly. That should work though it is a work around method.
I had the similar problem, on some action, the requirement was to delete the view2 and show view1 abd view3 only. There I have followed the same way. I still have the sample of it too.
Try it out.
VinExpert
ASKER
all the information helps me to do my splitter.
Thanks, with some late. :)
Thanks, with some late. :)
This article demonstrates how to use a static splitter window in a traditional SDI document-view architecture. The article shows how to design an application that can switch between a single view and a splitter window that can embed as many panes as necessary.
You can easily expand the code to support static splitter windows with different numbers of panes, depending on some run-time conditions.