I found this
http://www.codeguru.com/cpp/w-d/splitter/article.php/c1533[
^]
it works, except for the document, I have a null pointer when I try to retreive it, but anyway using NULL as document everything works.
CDocTemplate *pAmortDocTemplate = new CSingleDocTemplate(
IDR_MAINFRAME,
RUNTIME_CLASS(CMyDoc),
RUNTIME_CLASS(CMainFrame), // main SDI frame window
RUNTIME_CLASS(CView1)); //change the class with the view you want to be displayed as default
//you can extend this so the program saves the active view (not the view J , only information about which one was active), and you can
//restore the last one when the program will start again
AddDocTemplate(pAmortDocTemplate);
void CMainFrame::OnView1()
{
// TODO: Add your command handler code here
CRect cr;
GetClientRect(&cr);
CSize paneSize1(3*cr.Width()/4, cr.Height());
CCreateContext Context;
Context.m_pNewViewClass=RUNTIME_CLASS(CView1);
!!!I GET A NULLPOINTER :-(!!!!Context.m_pCurrentDoc=((CMyApp*)AfxGetApp())->m_pDoc;
Context.m_pCurrentFrame=this;
Context.m_pNewDocTemplate=Context.m_pCurrentDoc->GetDocTemplate();
Context.m_pLastView=(CView*)m_wndSplitter.GetPane(0,0);
m_wndSplitter.DeleteView(0, 1);
m_wndSplitter.CreateView(0, 1,RUNTIME_CLASS(CView1),paneSize1, &Context);
CView1 *pView=(CView1*)m_wndSplitter.GetPane(0,1);
pView-GetParentFrame()->RecalcLayout();
m_wndSplitter.RecalcLayout();
pView->OnInitialUpdate();
m_wndSplitter.SetActivePane(0,1);
}
//this one is only to gray out the menu item (and/or toolbar button) that corresponds to the active view
void CMainFrame::OnUpdateView1(CCmdUI* pCmdUI)
{
// TODO: Add your command update UI handler code here
pCmdUI->Enable(!m_wndSplitter.GetPane(0,1)->IsKindOf( RUNTIME_CLASS(CView1)));
}
BOOL CMainFrame::Create(LPCTSTR lpszClassName, LPCTSTR lpszWindowName,
DWORD dwStyle, const RECT& rect,
CWnd* pParentWnd, UINT nID, CCreateContext* pContext)
{
// TODO: Add your specialized code here and/or call the base class
return CWnd::Create(lpszClassName, lpszWindowName, dwStyle, rect, pParentWnd, nID, pContext);
}
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
CRect cr;
BOOL rc;
if (!m_wndSplitter.CreateStatic(this,1,2)){
TRACE0("Failed to create split bar ");
return FALSE; // failed to create
}
GetClientRect(&cr);
CSize paneSize(cr.Width()/4, cr.Height());
CSize paneSize1(3*cr.Width()/4, cr.Height());
((CMyApp*)AfxGetApp())->m_pDoc=(CMyDoc*)(pContext->m_pCurrentDoc);
pContext->m_pCurrentFrame=this;
rc=m_wndSplitter.CreateView(0, 1,pContext->m_pNewViewClass,paneSize1, pContext);
if(!rc)return FALSE;
pContext->m_pNewViewClass=RUNTIME_CLASS(CMyTree);
pContext->m_pCurrentDoc=((CMyApp*)AfxGetApp())->m_pDoc;
pContext->m_pCurrentFrame=this;
rc=m_wndSplitter.CreateView(0,0,pContext->m_pNewViewClass,paneSize,pContext);
m_wndSplitter.RecalcLayout();
m_wndSplitter.SetActivePane(0,1);
return rc;
}