Split window in MDI
-
Hi, I want 3 split windows in my application,in that left for Tree control and Right window act as a main window and bottom window have list control to show some log of my application. For that i made this code.. in Mainframe.cpp(), in OnCreateClient()
if(!m_SplitterWnd.CreateStatic(this, 2, 1))
return FALSE;CRect rect; GetClientRect(&rect); if(!m\_SplitterWnd.CreateView(1, 0, RUNTIME\_CLASS(CBottomView), CSize(rect.Width(), 50), pContext)) return FALSE; m\_SplitterWnd.SetRowInfo(0, 800, 50); m\_SplitterWnd.SetRowInfo(1, 330, 50); if (!m\_SplitterWnd1.CreateStatic(&m\_SplitterWnd, 1, 2, WS\_CHILD | WS\_VISIBLE | WS\_BORDER |AFX\_IDW\_PANE\_FIRST, m\_SplitterWnd.IdFromRowCol(0,0))) return FALSE; // first pane if(!m\_SplitterWnd1.CreateView(0, 0, RUNTIME\_CLASS(CTreeMenuView), CSize(rect.Width()/5,rect.Height()-50), pContext)) return FALSE; //Second pane if(!m\_SplitterWnd1.CreateView(0, 1, RUNTIME\_CLASS(CMainWindowView), CSize(rect.Width()-rect.Width()/5,rect.Height()-50), pContext)) return FALSE; int nWidth=rect.Width(); m\_SplitterWnd1.SetColumnInfo(0, nWidth\*0.25, 50); m\_SplitterWnd1.SetColumnInfo(1, nWidth\*0.75, 50); return CMDIFrameWnd::OnCreateClient(lpcs, pContext);
And i have to attach all my child window in right side window( CMainWindowView).. In my app class,
pDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME,
RUNTIME_CLASS(CABBHarmonyDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMainWindowView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);pGraphViewTemplate = new CMultiDocTemplate( IDR\_MAINFRAME, RUNTIME\_CLASS(CABBHarmonyDoc), RUNTIME\_CLASS(CChildFrame), RUNTIME\_CLASS(CGraphview)); AddDocTemplate(pGraphViewTemplate);
So when i press F5,this GraphView should display in MainwindowView. But it does not appear.Whats the mistake i did? Pls help me.. in Mianframe.cpp
void CMainFrame::OnGraphview()
{if( pGraphDisplayFrame == NULL ) { CDocTemplate \*pTemplate = theApp.pGraphViewTemplate; CABBHarmonyDoc\* pDoc = new CABBHarmonyDoc; pGraphDisplayFrame = (CMDIChildWnd \*)pTemplate->CreateNewFrame( pDoc ,NULL ); if( pGraphDisplayFrame == NULL ) { AfxMessageBox( "Unable to Create Graph Display" ); return; } pTemplate->InitialUpdateFrame( pGraphDisplayFrame,NULL ); } else MDIActivate( pGraphDisplayF
-
Hi, I want 3 split windows in my application,in that left for Tree control and Right window act as a main window and bottom window have list control to show some log of my application. For that i made this code.. in Mainframe.cpp(), in OnCreateClient()
if(!m_SplitterWnd.CreateStatic(this, 2, 1))
return FALSE;CRect rect; GetClientRect(&rect); if(!m\_SplitterWnd.CreateView(1, 0, RUNTIME\_CLASS(CBottomView), CSize(rect.Width(), 50), pContext)) return FALSE; m\_SplitterWnd.SetRowInfo(0, 800, 50); m\_SplitterWnd.SetRowInfo(1, 330, 50); if (!m\_SplitterWnd1.CreateStatic(&m\_SplitterWnd, 1, 2, WS\_CHILD | WS\_VISIBLE | WS\_BORDER |AFX\_IDW\_PANE\_FIRST, m\_SplitterWnd.IdFromRowCol(0,0))) return FALSE; // first pane if(!m\_SplitterWnd1.CreateView(0, 0, RUNTIME\_CLASS(CTreeMenuView), CSize(rect.Width()/5,rect.Height()-50), pContext)) return FALSE; //Second pane if(!m\_SplitterWnd1.CreateView(0, 1, RUNTIME\_CLASS(CMainWindowView), CSize(rect.Width()-rect.Width()/5,rect.Height()-50), pContext)) return FALSE; int nWidth=rect.Width(); m\_SplitterWnd1.SetColumnInfo(0, nWidth\*0.25, 50); m\_SplitterWnd1.SetColumnInfo(1, nWidth\*0.75, 50); return CMDIFrameWnd::OnCreateClient(lpcs, pContext);
And i have to attach all my child window in right side window( CMainWindowView).. In my app class,
pDocTemplate = new CMultiDocTemplate(IDR_MAINFRAME,
RUNTIME_CLASS(CABBHarmonyDoc),
RUNTIME_CLASS(CChildFrame), // custom MDI child frame
RUNTIME_CLASS(CMainWindowView));
if (!pDocTemplate)
return FALSE;
AddDocTemplate(pDocTemplate);pGraphViewTemplate = new CMultiDocTemplate( IDR\_MAINFRAME, RUNTIME\_CLASS(CABBHarmonyDoc), RUNTIME\_CLASS(CChildFrame), RUNTIME\_CLASS(CGraphview)); AddDocTemplate(pGraphViewTemplate);
So when i press F5,this GraphView should display in MainwindowView. But it does not appear.Whats the mistake i did? Pls help me.. in Mianframe.cpp
void CMainFrame::OnGraphview()
{if( pGraphDisplayFrame == NULL ) { CDocTemplate \*pTemplate = theApp.pGraphViewTemplate; CABBHarmonyDoc\* pDoc = new CABBHarmonyDoc; pGraphDisplayFrame = (CMDIChildWnd \*)pTemplate->CreateNewFrame( pDoc ,NULL ); if( pGraphDisplayFrame == NULL ) { AfxMessageBox( "Unable to Create Graph Display" ); return; } pTemplate->InitialUpdateFrame( pGraphDisplayFrame,NULL ); } else MDIActivate( pGraphDisplayF
You are allocating a new uninitialized instance of your document in
OnGraphView()
and use it for creation of the new frame. You should replace thepDoc
parameter by your existing document. You may also move theOnGraphView()
handler from the main frame class to your document class (passing thenthis
for the document pointer). Because the graph can be only shown when a document has been loaded.