在View视图类中使用CSplitterWnd来拆分视图窗口(不在CMainFrame类的虚函数OnCreateClient中拆分视图框架窗口)

// View.h CSplitterWnd m_wndSplitter; BOOL m_bSplitter; // 初始化为FALSE // View.cpp int CXXXView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CFormView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here if(NULL == m_wndSplitter.GetSafeHwnd()) { CCreateContext cc; memset(&cc, 0, sizeof(CCreateContext)); CRect rc; GetWindowRect(&rc); VERIFY(m_wndSplitter.CreateStatic(this, 1, 2, WS_CHILD | WS_VISIBLE)); cc.m_pNewViewClass = RUNTIME_CLASS(CLeftView); VERIFY(m_wndSplitter.CreateView(0, 0, RUNTIME_CLASS(CLeftView), CSize(300, rc.Height()), &cc)); cc.m_pNewViewClass = RUNTIME_CLASS(CRightView); VERIFY(m_wndSplitter.CreateView(0, 1, RUNTIME_CLASS(CRightView), CSize(0, rc.Height()), &cc)); m_wndSplitter.MoveWindow(0, 0, rc.Width(), rc.Height()); m_bSplitter = TRUE; } return 0; } void CXXXView::OnSize(UINT nType, int cx, int cy) { CFormView::OnSize(nType, cx, cy); // TODO: Add your message handler code here if(m_bSplitter && m_wndSplitter.GetSafeHwnd()) { m_wndSplitter.MoveWindow(0, 0, cx, cy); } }

你可能感兴趣的:(框架,null,Class)