본문 바로가기
나머지/IT개발.잡다한것.

[MFC, C++] 클래스 포인터 얻기

by 무늬만학생 2012. 10. 24.
반응형

App 클래스에서

CMainFrame *pMain=(CMainFrame *)AfxGetMainWnd();              //App -> MainFrm

CClassView *pView=(CClassView *)pMain->GetActiveView();     //App -> MainFrm -> View

CClassDoc *pDoc=(CClassDoc *)pMain->GetActiveDocument();   //App -> MainFrm -> Doc

 

View 클래스에서

void CClassView::OnMenuView()

CClassApp *pApp=(CClassApp *)AfxGetApp();                   //View -> App

CMainFrame *pMain=(CMainFrame *)AfxGetMainWnd();     //View -> MainFrm

CClassDoc *pDoc=(CClassDoc *)pMain->GetActiveDocument();    //View -> MainFrm -> Doc

CClassDoc *pDoc=(CClassDoc *)GetDocument();               //View -> Doc


MainFrame 클래스에서

CClassView *pView=(CClassView *)GetActiveView();     //MainFrm -> View

CClassDoc *pDoc=(CClassDoc *)GetActiveDocument();  //MainFrm -> Doc

CClassApp *pApp=(CClassApp *)AfxGetApp();               //MainFrm -> App


Doc 클래스에서

CClassApp *pApp=(CClassApp *)AfxGetApp();                    //Doc -> App

CMainFrame *pMain=(CMainFrame *)AfxGetMainWnd();       //Doc -> MainFrm

CClassView *pView=(CClassView *)pMain->GetActiveView();  // Doc -> MainFrm -> View

CClassView *pView=(CClassView *)m_viewList.GetHead();      // Doc -> View


-끝-

반응형

댓글0