실행과 동시에 프로그램은 m_pMainWnd 변수에 View를 등록한다. 어디에서든지 AfxGetMainWnd()를 호출하면 CWnd*가 얻어지는데 이를 CMainFrame*로 변환해서 사용하면 된다
#include "MainFrm.h" void CMyView::GetMainFrame() { CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd(); }
특정 View를 얻으시려면 CMainFrame 내에서 얻는 함수를 작성하시면 됩니다.
#include "MyView.h" #include "MyDoc.h"
이 처럼, 뷰와 도큐먼트를 선언한 헤더 파일을 포함하는 두 줄은 반드시 포함 되어 있어야 한다. 만약, 없게 되면 선언되지 않은 클래스라는 둥 Error를 뱉어낸다.
View가 하나일 경우
CMfcAppView* CMyView::GetMfcAppView() { return (CMfcAppView*)GetActiveView(); }
뷰가 분할(SplittWindow, SplittWnd) or MultiView 일 경우
(SDI 환경에서 Static 분할 View로 작성했다.)
CLeftView* CMainFrame::GetLeftView() { return m_wndSplitter.GetPane(0,0); } CRightView* CMainFrame::GetRightView() { return m_wndSplitter.GetPane(1,0); }
CDocument에서 View를 획득하는 방법
CLeftView* CMyDoc::GetLeftView() { return ((CMainFrame*)AfxGetMainWnd())->GetLeftView(); }
'MISCELLANEOUSNESS' 카테고리의 다른 글
Graphics] DirectX WM_SIZE 이벤트 처리 (0) | 2009.12.12 |
---|---|
2차] 컴퍼넌트 설치 완성 (0) | 2009.12.10 |
1차] 미니 컴퍼넌트 설치 하기~ (0) | 2009.12.09 |