1. MainFrame 포인터 얻기
CMainFrame *frame = (CMainFrame*)AfxGetMainWnd();
2. Doc 클래스 포인터 얻기
CxxxDoc *pDoc = (CxxxDoc*)(frame->GetActivedocument());
3. View 클래스 포인터 얻기
CxxxView* pView = (CxxxView*)((CMainFrame*)(AfxGetApp()->m_pMainWnd))->GetActiveView();
자주쓰이는 MFC 클래스 간의 통신입니다. 외워쓰기에는 시간이 아깝고, 매번 찾으려면 귀찮았는데 한번에 모아놓으니 편리하네요.^^
[SDI 형태]
1. MainFrame 얻기
- CMainFrame *pFrame = (CmainFrame *) AfxGetMainWnd();
2. App 포인터 얻기
- CTestApp *pApp = (CtestApp *) AfxGetApp();
3. Document 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CTestDoc *pDoc = (CTestDoc *)pFrame->GetActiveDocument();
- CTestDoc *pDoc = ((CMainFrame *)AfxGetMainWnd())->GetActiveDocument();
4. View 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CTestView *pView = (CTestView *)pFrame->GetActiveView();
- CTestView *pView = ((CMainFrame *)AfxGetMainWnd())->GetActiveView();
1. MainFrame 얻기
- CMainFrame *pFrame = (CmainFrame *) AfxGetMainWnd();
2. App 포인터 얻기
- CTestApp *pApp = (CtestApp *) AfxGetApp();
3. Document 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CTestDoc *pDoc = (CTestDoc *)pFrame->GetActiveDocument();
- CTestDoc *pDoc = ((CMainFrame *)AfxGetMainWnd())->GetActiveDocument();
4. View 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CTestView *pView = (CTestView *)pFrame->GetActiveView();
- CTestView *pView = ((CMainFrame *)AfxGetMainWnd())->GetActiveView();
[MDI 형태]
1. ChildFrame 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
- CChildFrame *pChild = ((CMainFrame *)AfxGetMainWnd())->GetActiveFrame();
2. Document 포인터 얻기
- CMainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
CMdiTestDoc *pDoc = (CMdiTestDoc *)pChild->GetActiveDocument();
- CMdiTestDoc *pDoc = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveDocument();
3. View 포인터 얻기
- CCainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
CMdiTestView *pView = (CMdiTestDoc *)pChild->GetActiveView();
- CMdiTestView *pView = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveView();
1. ChildFrame 포인터 얻기
- CMainFrame *pFrame = (CMainFrame *)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
- CChildFrame *pChild = ((CMainFrame *)AfxGetMainWnd())->GetActiveFrame();
2. Document 포인터 얻기
- CMainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
CMdiTestDoc *pDoc = (CMdiTestDoc *)pChild->GetActiveDocument();
- CMdiTestDoc *pDoc = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveDocument();
3. View 포인터 얻기
- CCainFrame *pFrame = (CMainFrame)AfxGetMainWnd();
CChildFrame *pChild = (CChildFrame *)pFrame->GetActiveFrame();
CMdiTestView *pView = (CMdiTestDoc *)pChild->GetActiveView();
- CMdiTestView *pView = (((CMainFrame *)AfxGetMainWnd())->GetActiveFrame())->GetActiveView();
'프로그래밍 > VC++' 카테고리의 다른 글
Dialog Based의 트리컨트롤에서 Enter키를 눌러서 라벨내용 바꾸는 경우 (0) | 2007.08.16 |
---|---|
다이얼로그에서 ESC나 Enter키 눌렀다고 창 닫혀지지 않도록 하기 (0) | 2007.08.16 |
ActiveX 빌드 후 bin 디렉토리에 복사하는 이벤트 (0) | 2007.08.02 |
GDI+에서 리소스 비트맵 가져와서 쓰기 (0) | 2007.07.23 |
이미지 회전변환 (0) | 2007.07.11 |