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. Toolbar for bottom split window - CSplitterWnd

Toolbar for bottom split window - CSplitterWnd

Scheduled Pinned Locked Moved C / C++ / MFC
c++question
8 Posts 2 Posters 2 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

    I have MDI MFC application. For a particular child window, i want to split in to two. Already i have toolbar for topview by using OnCreate() in ChildFrame.cpp. I want to add toolbar for bottom view also. ChildFrame OnCreateClient() code:

    BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
    {
    // TODO: Add your specialized code here and/or call the base class

    if(iWindowNumber == 4)
    {

    CRect cr; 
    GetClientRect( &cr);
    
    if (!m\_wndSplitter.CreateStatic(this, 2, 1))
    	return FALSE;
    
    if(!m\_wndSplitter.CreateView(0,0, RUNTIME\_CLASS(CTrendView),CSize(cr.Width(), cr.Height()-200),pContext)||		
    	!m\_wndSplitter.CreateView(1,0, RUNTIME\_CLASS(CTrendListView),CSize(cr.Width(), cr.Height()-550),pContext))
    {
    	m\_wndSplitter.DestroyWindow();
    	return FALSE;
    }
    //m\_wndSplitter.SetActivePane(1, 0);
    return TRUE;
    

    }
    return CMDIChildWnd::OnCreateClient(lpcs, pContext);
    }

    In OnCreate(), im loading toolbar, but it adds only for TopView. I want to add different toolbar for bootmView. Can we add toolbar using CView::OnCreate()? i tried this but it is not happening. Otherwise i have to create 3 splitter window, middle winodw will have toolbar buttons that can be added using CMiddleView::OnCreate(). How can i get that?

    Anu

    V 1 Reply Last reply
    0
    • A Anu_Bala

      I have MDI MFC application. For a particular child window, i want to split in to two. Already i have toolbar for topview by using OnCreate() in ChildFrame.cpp. I want to add toolbar for bottom view also. ChildFrame OnCreateClient() code:

      BOOL CChildFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
      {
      // TODO: Add your specialized code here and/or call the base class

      if(iWindowNumber == 4)
      {

      CRect cr; 
      GetClientRect( &cr);
      
      if (!m\_wndSplitter.CreateStatic(this, 2, 1))
      	return FALSE;
      
      if(!m\_wndSplitter.CreateView(0,0, RUNTIME\_CLASS(CTrendView),CSize(cr.Width(), cr.Height()-200),pContext)||		
      	!m\_wndSplitter.CreateView(1,0, RUNTIME\_CLASS(CTrendListView),CSize(cr.Width(), cr.Height()-550),pContext))
      {
      	m\_wndSplitter.DestroyWindow();
      	return FALSE;
      }
      //m\_wndSplitter.SetActivePane(1, 0);
      return TRUE;
      

      }
      return CMDIChildWnd::OnCreateClient(lpcs, pContext);
      }

      In OnCreate(), im loading toolbar, but it adds only for TopView. I want to add different toolbar for bootmView. Can we add toolbar using CView::OnCreate()? i tried this but it is not happening. Otherwise i have to create 3 splitter window, middle winodw will have toolbar buttons that can be added using CMiddleView::OnCreate(). How can i get that?

      Anu

      V Offline
      V Offline
      Victor Nijegorodov
      wrote on last edited by
      #2

      [Toolbar in splitter window pane](https://www.codeproject.com/Articles/2285/Toolbar-in-splitter-window-pane)

      A 1 Reply Last reply
      0
      • V Victor Nijegorodov

        [Toolbar in splitter window pane](https://www.codeproject.com/Articles/2285/Toolbar-in-splitter-window-pane)

        A Offline
        A Offline
        Anu_Bala
        wrote on last edited by
        #3

        In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.

        int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
        {
        if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
        return -1;
        // TODO: Add your specialized creation code here

        struct tagSIZE butSize,bmpSize;
        bmpSize.cx = 25;bmpSize.cy = 23;butSize.cx = 35;butSize.cy = 30;
        if(iWindowNumber == 4)
        {
        	if (!m\_wndWindowTool.Create(this,CBRS\_TOP|CBRS\_TOOLTIPS|CBRS\_FLYBY|WS\_VISIBLE | CBRS\_FLOAT\_MULTI) ||
        		!m\_wndWindowTool.LoadBitmap(IDB\_GROUPVW) ||
        		!m\_wndWindowTool.SetButtons(CtrlGrp,
        		sizeof(CtrlGrp)/sizeof(UINT)))
        	{
        		TRACE0("Failed to create toolbar\\n");
        		return -1;      
        	}
        	m\_wndWindowTool.SetWindowText("Trend");
        	m\_wndWindowTool.SetSizes( butSize,bmpSize );
        	m\_wndWindowTool.SetHeight( 40 );
        
        	
        	CRect rect;
        	m\_wndWindowTool.GetItemRect(0, &rect);
        	
        	
        	m\_wndWindowTool.m\_Static.IsTitle = true;
        	if (!m\_wndWindowTool.m\_Static.Create("Title",WS\_CHILD|WS\_VISIBLE|BS\_OWNERDRAW,rect, &m\_wndWindowTool, IDD\_TITLESTATIC) )
        	{
        		TRACE0("Failed to create combo-box\\n");
        		return FALSE;
        	}
        		}
        

        }

        Anu

        V 1 Reply Last reply
        0
        • A Anu_Bala

          In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.

          int CChildFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
          {
          if (CMDIChildWnd::OnCreate(lpCreateStruct) == -1)
          return -1;
          // TODO: Add your specialized creation code here

          struct tagSIZE butSize,bmpSize;
          bmpSize.cx = 25;bmpSize.cy = 23;butSize.cx = 35;butSize.cy = 30;
          if(iWindowNumber == 4)
          {
          	if (!m\_wndWindowTool.Create(this,CBRS\_TOP|CBRS\_TOOLTIPS|CBRS\_FLYBY|WS\_VISIBLE | CBRS\_FLOAT\_MULTI) ||
          		!m\_wndWindowTool.LoadBitmap(IDB\_GROUPVW) ||
          		!m\_wndWindowTool.SetButtons(CtrlGrp,
          		sizeof(CtrlGrp)/sizeof(UINT)))
          	{
          		TRACE0("Failed to create toolbar\\n");
          		return -1;      
          	}
          	m\_wndWindowTool.SetWindowText("Trend");
          	m\_wndWindowTool.SetSizes( butSize,bmpSize );
          	m\_wndWindowTool.SetHeight( 40 );
          
          	
          	CRect rect;
          	m\_wndWindowTool.GetItemRect(0, &rect);
          	
          	
          	m\_wndWindowTool.m\_Static.IsTitle = true;
          	if (!m\_wndWindowTool.m\_Static.Create("Title",WS\_CHILD|WS\_VISIBLE|BS\_OWNERDRAW,rect, &m\_wndWindowTool, IDD\_TITLESTATIC) )
          	{
          		TRACE0("Failed to create combo-box\\n");
          		return FALSE;
          	}
          		}
          

          }

          Anu

          V Offline
          V Offline
          Victor Nijegorodov
          wrote on last edited by
          #4

          Anu_Bala wrote:

          In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.

          Did you read the article? Did you download the code to test/debug it to know how it works?

          A 1 Reply Last reply
          0
          • V Victor Nijegorodov

            Anu_Bala wrote:

            In my CChildFrame::OnCreate(), im loading toolbar but it comes only for top view. But i want for bottom view.

            Did you read the article? Did you download the code to test/debug it to know how it works?

            A Offline
            A Offline
            Anu_Bala
            wrote on last edited by
            #5

            I saw that one show CFrameWnd. My window is CMDIChildWnd. So i didnt try first. I tried now. i create CSPlitFrame as CFrameWnd and i coded like below. But when i want my particular window , it shows error on calling that view in Mainframe.cpp.

            BEGIN_MESSAGE_MAP(CSplitFrame, CFrameWnd)
            ON_WM_CREATE()
            END_MESSAGE_MAP()

            BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
            {

            CTrendListView \*pview;
            
            // Create a context.
            CCreateContext context;
            pContext = &context;
            
            // Assign custom view.
            pContext->m\_pNewViewClass = RUNTIME\_CLASS(CTrendListView);
            
            // Create the view.
            pview = (CTrendListView \*) CreateView(pContext, AFX\_IDW\_PANE\_FIRST);
            if (pview == NULL)
            	return FALSE;
            
            // Notify the view.
            //pview->SendMessage(WM\_INITIALUPDATE);
            SetActiveView(pview, FALSE);
            
            return TRUE;
            

            }

            int CSplitFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
            {
            if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
            return -1;

            // TODO:  Add your specialized creation code here
            
            
            if (!m\_wndWindowTool.CreateEx(this, TBSTYLE\_FLAT, WS\_CHILD | WS\_VISIBLE | CBRS\_TOP
            	| CBRS\_GRIPPER | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_DYNAMIC) ||
            	!m\_wndWindowTool.LoadToolBar(IDR\_MAINFRAME))
            {
            	TRACE0("Failed to create toolbar\\n");
            	return -1;      // fail to create
            }
            
            m\_wndWindowTool.EnableDocking(CBRS\_ALIGN\_ANY);
            

            m_wndWindowTool.SetBorders(3, 3, 3, 3);
            EnableDocking(CBRS_ALIGN_ANY);
            DockControlBar(&m_wndWindowTool);
            return 0;

            }

            CChildFrame.cpp OnCreateClient()

            if (!m_wndSplitter.CreateStatic(this, 2, 1))
            return FALSE;

            if(!m\_wndSplitter.CreateView(0,0, RUNTIME\_CLASS(CTrendView),CSize(cr.Width(), cr.Height()-200),pContext)||		
            	!m\_wndSplitter.CreateView(1,0, RUNTIME\_CLASS(CSplitFrame),CSize(cr.Width(), cr.Height()-550),pContext))
            {
            	m\_wndSplitter.DestroyWindow();
            	return FALSE;
            }
            

            But it shows error in calling TrendView()

            if( pTrendDisplayFrame == NULL )
            {
            iWindowNumber = 4;
            CDocTemplate *pTemplate = theApp.pTrendViewTemplate;
            CCS3OprDoc* pDoc = new CCS3OprDoc;
            pTrendDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL ); //It shows error in creating new MDIChhildWnd
            if( pTrendDisplayFrame == NULL )
            {
            MessageBox( "Unable to Create Trend Display" );
            return;
            }
            pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
            }
            else
            MDIActivate( pTrendDisplayFrame );

            When i create SplitFrame as MDICHildWnd, it shows asse

            V 1 Reply Last reply
            0
            • A Anu_Bala

              I saw that one show CFrameWnd. My window is CMDIChildWnd. So i didnt try first. I tried now. i create CSPlitFrame as CFrameWnd and i coded like below. But when i want my particular window , it shows error on calling that view in Mainframe.cpp.

              BEGIN_MESSAGE_MAP(CSplitFrame, CFrameWnd)
              ON_WM_CREATE()
              END_MESSAGE_MAP()

              BOOL CSplitFrame::OnCreateClient(LPCREATESTRUCT /*lpcs*/, CCreateContext* pContext)
              {

              CTrendListView \*pview;
              
              // Create a context.
              CCreateContext context;
              pContext = &context;
              
              // Assign custom view.
              pContext->m\_pNewViewClass = RUNTIME\_CLASS(CTrendListView);
              
              // Create the view.
              pview = (CTrendListView \*) CreateView(pContext, AFX\_IDW\_PANE\_FIRST);
              if (pview == NULL)
              	return FALSE;
              
              // Notify the view.
              //pview->SendMessage(WM\_INITIALUPDATE);
              SetActiveView(pview, FALSE);
              
              return TRUE;
              

              }

              int CSplitFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
              {
              if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
              return -1;

              // TODO:  Add your specialized creation code here
              
              
              if (!m\_wndWindowTool.CreateEx(this, TBSTYLE\_FLAT, WS\_CHILD | WS\_VISIBLE | CBRS\_TOP
              	| CBRS\_GRIPPER | CBRS\_TOOLTIPS | CBRS\_FLYBY | CBRS\_SIZE\_DYNAMIC) ||
              	!m\_wndWindowTool.LoadToolBar(IDR\_MAINFRAME))
              {
              	TRACE0("Failed to create toolbar\\n");
              	return -1;      // fail to create
              }
              
              m\_wndWindowTool.EnableDocking(CBRS\_ALIGN\_ANY);
              

              m_wndWindowTool.SetBorders(3, 3, 3, 3);
              EnableDocking(CBRS_ALIGN_ANY);
              DockControlBar(&m_wndWindowTool);
              return 0;

              }

              CChildFrame.cpp OnCreateClient()

              if (!m_wndSplitter.CreateStatic(this, 2, 1))
              return FALSE;

              if(!m\_wndSplitter.CreateView(0,0, RUNTIME\_CLASS(CTrendView),CSize(cr.Width(), cr.Height()-200),pContext)||		
              	!m\_wndSplitter.CreateView(1,0, RUNTIME\_CLASS(CSplitFrame),CSize(cr.Width(), cr.Height()-550),pContext))
              {
              	m\_wndSplitter.DestroyWindow();
              	return FALSE;
              }
              

              But it shows error in calling TrendView()

              if( pTrendDisplayFrame == NULL )
              {
              iWindowNumber = 4;
              CDocTemplate *pTemplate = theApp.pTrendViewTemplate;
              CCS3OprDoc* pDoc = new CCS3OprDoc;
              pTrendDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL ); //It shows error in creating new MDIChhildWnd
              if( pTrendDisplayFrame == NULL )
              {
              MessageBox( "Unable to Create Trend Display" );
              return;
              }
              pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
              }
              else
              MDIActivate( pTrendDisplayFrame );

              When i create SplitFrame as MDICHildWnd, it shows asse

              V Offline
              V Offline
              Victor Nijegorodov
              wrote on last edited by
              #6

              Anu_Bala wrote:

              When i create SplitFrame as MDICHildWnd, it shows assertion error.

              Where exactly the Assertion fails?

              A 1 Reply Last reply
              0
              • V Victor Nijegorodov

                Anu_Bala wrote:

                When i create SplitFrame as MDICHildWnd, it shows assertion error.

                Where exactly the Assertion fails?

                A Offline
                A Offline
                Anu_Bala
                wrote on last edited by
                #7

                If i use

                class CSplitFrame : public CframeWnd

                Here, I call the TrendView using following fucntion in mainfrm.cpp,

                void CMainFrame::OnTrendview()
                {

                if( pTrendDisplayFrame == NULL )
                {
                	iWindowNumber = 4;
                	CDocTemplate \*pTemplate = theApp.pTrendViewTemplate;
                	CCS3OprDoc\* pDoc = new CCS3OprDoc;
                	pTrendDisplayFrame = (CMDIChildWnd \*)pTemplate->CreateNewFrame( pDoc ,NULL );
                	if( pTrendDisplayFrame == NULL )
                	{
                		MessageBox( "Unable to Create Trend Display" );
                		return;
                	}
                	pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
                }
                else
                	MDIActivate( pTrendDisplayFrame );
                

                }

                Here it comes messagebox “Unable to create trend display” becoz pTrendDisplayFrmae is null. Frame is not created in CreateNewFrame(),it return null from this function call from doctempl.cpp

                // create new from resource
                if (!pFrame->LoadFrame(m_nIDResource,
                WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, // default frame styles
                NULL, &context))
                {
                TRACE(traceAppMsg, 0, "Warning: CDocTemplate couldn't create a frame.\n");
                // frame will be deleted in PostNcDestroy cleanup
                return NULL;
                }

                When I use CsplitFrame as MDIChilWNd

                class CSplitFrame : public CMDIChildWnd

                IT shows assertion error in winmdi.cpp

                // walk up two parents for MDIFrame that owns MDIChild (skip MDIClient)
                CMDIFrameWnd* CMDIChildWnd::GetMDIFrame()
                {
                ASSERT_KINDOF(CMDIChildWnd, this);
                ASSERT(m_hWnd != NULL);
                HWND hWndMDIClient = ::GetParent(m_hWnd);
                ASSERT(hWndMDIClient != NULL);

                CMDIFrameWnd\* pMDIFrame;
                pMDIFrame = (CMDIFrameWnd\*)CWnd::FromHandle(::GetParent(hWndMDIClient));
                ASSERT(pMDIFrame != NULL);
                ASSERT\_KINDOF(CMDIFrameWnd, pMDIFrame); //Assertion error occurred here
                ASSERT(pMDIFrame->m\_hWndMDIClient == hWndMDIClient);
                ASSERT\_VALID(pMDIFrame);
                return pMDIFrame;
                

                }

                My TrendView base class is

                class CTrendView : public CView

                TrendListView base class is also CView

                class CTrendListView : public CView

                Im invoking this TrendListView as follow

                void CMainFrame::OnTrendListView()
                {
                // TODO: Add your command handler code here
                iGraphView = 0; //Code added by Mohan //Graph view inactive
                if( pTrendListDisplayFrame == NULL )
                {
                iWindowNumber = 11;
                CDocTemplate *pTemplate = theApp.pTrendListViewTemplate;
                CCS3OprDoc* pDoc = new CCS3OprDoc;
                pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNew

                V 1 Reply Last reply
                0
                • A Anu_Bala

                  If i use

                  class CSplitFrame : public CframeWnd

                  Here, I call the TrendView using following fucntion in mainfrm.cpp,

                  void CMainFrame::OnTrendview()
                  {

                  if( pTrendDisplayFrame == NULL )
                  {
                  	iWindowNumber = 4;
                  	CDocTemplate \*pTemplate = theApp.pTrendViewTemplate;
                  	CCS3OprDoc\* pDoc = new CCS3OprDoc;
                  	pTrendDisplayFrame = (CMDIChildWnd \*)pTemplate->CreateNewFrame( pDoc ,NULL );
                  	if( pTrendDisplayFrame == NULL )
                  	{
                  		MessageBox( "Unable to Create Trend Display" );
                  		return;
                  	}
                  	pTemplate->InitialUpdateFrame( pTrendDisplayFrame,NULL );
                  }
                  else
                  	MDIActivate( pTrendDisplayFrame );
                  

                  }

                  Here it comes messagebox “Unable to create trend display” becoz pTrendDisplayFrmae is null. Frame is not created in CreateNewFrame(),it return null from this function call from doctempl.cpp

                  // create new from resource
                  if (!pFrame->LoadFrame(m_nIDResource,
                  WS_OVERLAPPEDWINDOW | FWS_ADDTOTITLE, // default frame styles
                  NULL, &context))
                  {
                  TRACE(traceAppMsg, 0, "Warning: CDocTemplate couldn't create a frame.\n");
                  // frame will be deleted in PostNcDestroy cleanup
                  return NULL;
                  }

                  When I use CsplitFrame as MDIChilWNd

                  class CSplitFrame : public CMDIChildWnd

                  IT shows assertion error in winmdi.cpp

                  // walk up two parents for MDIFrame that owns MDIChild (skip MDIClient)
                  CMDIFrameWnd* CMDIChildWnd::GetMDIFrame()
                  {
                  ASSERT_KINDOF(CMDIChildWnd, this);
                  ASSERT(m_hWnd != NULL);
                  HWND hWndMDIClient = ::GetParent(m_hWnd);
                  ASSERT(hWndMDIClient != NULL);

                  CMDIFrameWnd\* pMDIFrame;
                  pMDIFrame = (CMDIFrameWnd\*)CWnd::FromHandle(::GetParent(hWndMDIClient));
                  ASSERT(pMDIFrame != NULL);
                  ASSERT\_KINDOF(CMDIFrameWnd, pMDIFrame); //Assertion error occurred here
                  ASSERT(pMDIFrame->m\_hWndMDIClient == hWndMDIClient);
                  ASSERT\_VALID(pMDIFrame);
                  return pMDIFrame;
                  

                  }

                  My TrendView base class is

                  class CTrendView : public CView

                  TrendListView base class is also CView

                  class CTrendListView : public CView

                  Im invoking this TrendListView as follow

                  void CMainFrame::OnTrendListView()
                  {
                  // TODO: Add your command handler code here
                  iGraphView = 0; //Code added by Mohan //Graph view inactive
                  if( pTrendListDisplayFrame == NULL )
                  {
                  iWindowNumber = 11;
                  CDocTemplate *pTemplate = theApp.pTrendListViewTemplate;
                  CCS3OprDoc* pDoc = new CCS3OprDoc;
                  pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNew

                  V Offline
                  V Offline
                  Victor Nijegorodov
                  wrote on last edited by
                  #8

                  Anu_Bala wrote:

                  Im invoking this TrendListView as follow

                  void CMainFrame::OnTrendListView()
                  {
                  // TODO: Add your command handler code here
                  iGraphView = 0; //Code added by Mohan //Graph view inactive
                  if( pTrendListDisplayFrame == NULL )
                  {
                  iWindowNumber = 11;
                  CDocTemplate *pTemplate = theApp.pTrendListViewTemplate;
                  CCS3OprDoc* pDoc = new CCS3OprDoc;
                  pTrendListDisplayFrame = (CMDIChildWnd *)pTemplate->CreateNewFrame( pDoc ,NULL );
                  if( pTrendListDisplayFrame == NULL )
                  {
                  AfxMessageBox( "Unable to Create Tuning Display" );
                  return;
                  }
                  pTemplate->InitialUpdateFrame( pTrendListDisplayFrame ,NULL );
                  }
                  else
                  MDIActivate( pTrendListDisplayFrame );

                  }

                  What is the theApp.pTrendListViewTemplate? How is it defined/initialized?

                  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