Post List

2014년 12월 25일 목요일

MFC :: MainFrame,Doc,View의 포인터 얻기

 MainFrame,Doc,View의 포인터 얻기
※ 주의할점 : 얻어올 포인터의 헤더 정보를 include하여야 하며 순서에 유의하자!

CMainFrame* pFrame = (CMainFrame*)AfxGetApp()->GetMainWnd(); 


1. MainFrame 포인터 얻기
CMainFrame *frame = (CMainFrame*)AfxGetMainWnd();

2. Doc 클래스 포인터 얻기
CxxxDoc *pDoc = (CxxxDoc*)(frame->GetActivedocument());

3. View 클래스 포인터 얻기
CxxxView* pView = (CxxxView*)((CMainFrame*)(AfxGetApp()->m_pMainWnd))->GetActiveView();
[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();
 

[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();




원문 : http://printf.egloos.com/viewer/1940633

댓글 없음:

댓글 쓰기