View 분할하기
OnCreate 에서 다음과 같이 정의한다. 여기서 View 는 new로 할당되는 포인터이어야 하고, 삭제는 CSplitterWnd에서 자동으로 하기 때문에 new로 할당은 하더라도 삭제는 하지 않음에 주의한다.
int CSplitSampleView::OnCreate(LPCREATESTRUCT lpCreateStruct) { if (CView::OnCreate(lpCreateStruct) == -1) return -1; // TODO: Add your specialized creation code here if (!m_wndSplitter.CreateStatic (this, 2, 1)) { ASSERT(FALSE); return FALSE; } m_pView1 = new CEditView; m_pView2 = new CEditView; CCreateContext context; context.m_pCurrentDoc = GetDocument(); DWORD dwStyle = WS_CHILD | WS_VISIBLE; BOOL blSuccess = m_pView1->Create(NULL, _T("test1"), dwStyle, CRect(0,0,0,0), &m_wndSplitter, m_wndSplitter.IdFromRowCol (0, 0), (CCreateContext*)&context); if(blSuccess == FALSE) { return FALSE; } m_pView1->SendMessage(WM_INITIALUPDATE); blSuccess = m_pView2->Create(NULL, _T("test2"), dwStyle, CRect(0,0,0,0), &m_wndSplitter, m_wndSplitter.IdFromRowCol (1, 0), (CCreateContext*)&context/*lpCreateStruct->lpCreateParams*/); if(blSuccess == FALSE) { return FALSE; } m_pView2->SendMessage(WM_INITIALUPDATE); return 0; } |
그리고 OnSize 에서 다음과 같이 한다.
void CSplitSampleView::OnSize(UINT nType, int cx, int cy) { CView::OnSize(nType, cx, cy); if (m_wndSplitter.GetSafeHwnd () != NULL) { m_wndSplitter.SetWindowPos (this, 0, 0, cx, cy, SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_NOREDRAW); } } |