Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Split window in MDI

Split window in MDI

Scheduled Pinned Locked Moved C / C++ / MFC
data-structuresc++helpquestion
2 Posts 2 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Anu_Bala
    wrote on last edited by
    #1

    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
    
    J 1 Reply Last reply
    0
    • A Anu_Bala

      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
      
      J Offline
      J Offline
      Jochen Arndt
      wrote on last edited by
      #2

      You are allocating a new uninitialized instance of your document in OnGraphView() and use it for creation of the new frame. You should replace the pDoc parameter by your existing document. You may also move the OnGraphView() handler from the main frame class to your document class (passing then this for the document pointer). Because the graph can be only shown when a document has been loaded.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups