Problem with Splitter Wnd
-
I split the view of my application in two parts. My problem is that the status bar and toolbar disappear after the split and I don't know why!!! :confused: This is my code : int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { CCreateContext* pContext = (CCreateContext*)lpCreateStruct->lpCreateParams; int rc; CRect cr; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); GetClientRect(&cr); CSize paneSize(cr.Width() / 2, cr.Height()); m_wndSplitter.CreateStatic(this, 1, 2); if(!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CBOFListView), paneSize, pContext)) { TRACE0("Failed to create Splitter Wnd\n"); return -1; // fail to create } if(!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CBOFInfoView), paneSize, pContext)) { TRACE0("Failed to create Splitter Wnd\n"); return -1; // fail to create } return 0; } Best Regards!
-
I split the view of my application in two parts. My problem is that the status bar and toolbar disappear after the split and I don't know why!!! :confused: This is my code : int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct) { CCreateContext* pContext = (CCreateContext*)lpCreateStruct->lpCreateParams; int rc; CRect cr; if (CFrameWnd::OnCreate(lpCreateStruct) == -1) return -1; if (!m_wndToolBar.CreateEx(this, TBSTYLE_FLAT, WS_CHILD | WS_VISIBLE | CBRS_TOP | CBRS_GRIPPER | CBRS_TOOLTIPS | CBRS_FLYBY | CBRS_SIZE_DYNAMIC) || !m_wndToolBar.LoadToolBar(IDR_MAINFRAME)) { TRACE0("Failed to create toolbar\n"); return -1; // fail to create } if (!m_wndStatusBar.Create(this) || !m_wndStatusBar.SetIndicators(indicators, sizeof(indicators)/sizeof(UINT))) { TRACE0("Failed to create status bar\n"); return -1; // fail to create } // TODO: Delete these three lines if you don't want the toolbar to // be dockable m_wndToolBar.EnableDocking(CBRS_ALIGN_ANY); EnableDocking(CBRS_ALIGN_ANY); DockControlBar(&m_wndToolBar); GetClientRect(&cr); CSize paneSize(cr.Width() / 2, cr.Height()); m_wndSplitter.CreateStatic(this, 1, 2); if(!m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CBOFListView), paneSize, pContext)) { TRACE0("Failed to create Splitter Wnd\n"); return -1; // fail to create } if(!m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CBOFInfoView), paneSize, pContext)) { TRACE0("Failed to create Splitter Wnd\n"); return -1; // fail to create } return 0; } Best Regards!
Try to set CSize paneSize(200,200); then try to handle the OnSize message as follows: void CMainFrame::OnSize(UINT nType, int cx, int cy) { CFrameWnd::OnSize(nType, cx, cy); CRect cr; if ( m_initSplitters && nType != SIZE_MINIMIZED ) { m_mainSplitter.GetClientRect( &cr ); m_mainSplitter.SetColumnInfo( 0, cr.Width() / 2, 0 ); m_mainSplitter.SetColumnInfo( 1, cr.Width() / 2, 0 ); m_mainSplitter.RecalcLayout(); } } m_initSplitters is a BOOL set to TRUE after the splitters have been created in the OnCreateClient-function. Use this function to create your splitters instead of the OnCreate function regards!