2009년 6월 1일 월요일

CSplitterWnd 분할 윈도우 만들기

다시 개발을 시작했다.

개발 않할때는 손가락이 근질 거려 뭐라도 하고 싶었는데 ^^

막상 시작하니 ㅋㅋ 여전이 IT 개발은 빡세게 돌아가고 있구나... 후회가 된다. ㅋㅋㅋ

 

CFormView 에서 CSplitterWnd 사용 화면 분할

/// 물론 h 파일에는

///  CSplitterWnd m_wndSplit;
///  CSplitterWnd m_wndBottomSplit;

/// 분할 Wnd 선언

/// CMainFrame에서 생성
BOOL CMainFrame::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{

   m_wndSplit.CreateStatic(this, 6, 1); ///  가로 6개 분할

  m_wndBottomSplit.CreateStatic(&m_wndSplit, 1,2, WS_CHILD|WS_VISIBLE|WS_BORDER, m_wndSplit.IdFromRowCol(5, 0) );

  /// 마지막 6번째 화면을 가로로 분할 (화면은 0부터 Count)

 

m_wndSplit.CreateView(0,0,pContext->m_pNewViewClass, CSize(rect.Width(), 60), pContext);
 m_wndSplit.CreateView(1,0,RUNTIME_CLASS(CMiddileFrameWnd), CSize(rect.Width(), 200), pContext);

 m_wndSplit.CreateView(2,0,RUNTIME_CLASS(CKillorFormView), CSize(rect.Width(), 60), pContext);
 m_wndSplit.CreateView(3,0,RUNTIME_CLASS(CKillorFormView), CSize(rect.Width(), 60), pContext);
 m_wndSplit.CreateView(4,0,RUNTIME_CLASS(CKillorFormView), CSize(rect.Width(), 60), pContext);

 

 m_wndBottomSplit.CreateView(0,0, RUNTIME_CLASS(CKillorFormView), CSize(rect.Width()/2, nHight), pContext);

 m_wndBottomSplit.CreateView(0,1, RUNTIME_CLASS(CKillorFormView), CSize(rect.Width()/2, nHight), pContext);

 

 SetActiveView((CView *) m_wndSplit.GetPane(0,0));

 return TRUE; // 완료 반환

// return CFrameWnd::OnCreateClient(lpcs, pContext); 주석처리

}

 

//// 어케 이쁘게 분할 되었나? ^^ CSize를 수정하면 초기 크기 조절도 가능 ^^

/// RUNTIME_CLASS 에서 View Class  뿐 아니라 CFrameWnd 를 생성하여 Toolbar도 사용


/// CFrameWnd  사용시

/// CFrameWnd의 Client 생성시 view point 생성

BOOL CMiddileFrameWnd::OnCreateClient(LPCREATESTRUCT lpcs, CCreateContext* pContext)
{
 CMiddileFormView *pview;

 // Create a context.
 CCreateContext context;
 pContext = &context;

 // Assign custom view.
 pContext->m_pNewViewClass = RUNTIME_CLASS(CMiddileFormView);

 // Create the view.
 pview = (CMiddileFormView *) CreateView(pContext, AFX_IDW_PANE_FIRST);
 if (pview == NULL)
  return FALSE;

 // Notify the view.
 pview->SendMessage(WM_INITIALUPDATE);
 SetActiveView(pview, FALSE);

 return TRUE;//CFrameWnd::OnCreateClient(lpcs, pContext);
}

 

출처 - http://www.codeproject.com/ 


 

댓글 2개:

  1. 대소문자 가리기에 좀 빡세긴 하겠다..

    답글삭제
  2. @프랭크리 - 2009/06/02 01:15
    ㅋㅋㅋ ^^ 가려줄거는 가려주는 쎈쓰..

    답글삭제