본문 바로가기
C++

MFC Class cross reference

by 사무실 꿀벌 2020. 5. 28.
반응형

MFC Class cross reference

  • CWinApp
    CWinApp* AfxGetApp();
  • 메인프레임 윈도우
    CWnd* AfxGetMainWnd();
  • 뷰에서 도큐먼트
    Document* CView::GetDocument();
  • 뷰에서 뷰를 둘러싸고 있는 프레임윈도우
    CFrameWnd* CWnd::GetParentFrame();
  • 도큐먼트에서 뷰
    POSITION pos = GetFirstViewPosition();
    While(pos != NULL){ 
     CView* pView = (CView*)GetNextView(pos);
     if(pView->IsKindOf(RUNTIME_CLASS(CTestView))) {
      pView->UpdateWindow();  }
    }

  • 도큐먼트에서 프레임 윈도우
    단일 도큐먼트: AfxGetMainWnd();
    다중 도큐먼트: 도큐먼트에서 뷰를 얻고 그뷰에서 자신을 포함하는 프레임 윈도우
  • 프레임 윈도우에서 뷰
    CView* CFrameWnd::GetActiveView();
  • 프레임 윈도우에서 도큐먼트
    virtual CDocument* CFrameWnd::GetActiveDocument();

 

  • example
    1. CMainFrame* pFrame = (CMainFrame*)AfxGetMainWnd();
      CTESTDoc* pDoc = (CTESTDoc*)pFrame->GetActiveDocument();
      POSITION pos = pDoc->GetFirstViewPosition();
      CTESTView* pView = (CTESTView*)pDoc->GetNextView();
    2. CTESTDoc* pDoc = (CTESTDoc*)(((CMainFrame*)AfxGetMainWnd())->GetActiveDocument());
      POSITION pos = pDoc->GetFirstViewPosion();
      CTESTView* pView = (CTESTView*)pDoc->GetNextView(pos);
    3. CTESTDoc* pDoc = (CTESTDoc*)((CMainFrame*)AfxGetApp()->m_pMainWnd)->GetActiveDocument();
      POSITION pos = pDoc->GetFirstViewPosition();
      CTESTView* pView = (CTESTView*)pDoc->GetNextView(pos);
    4. CDocument* pDoc;
      CView *pView;
      POSITION pos;
      pDoc = (CDocument*)((CMainFrame*)AfxGetMainWnd())->GetActiveDocument();
      pos =pDoc->GetFirstViewPosition();
      pView = pDoc->GetNextView(pos);
    5. CTESTDoc* pDoc = GetDocument();
      CView *pView;
      POSITION pos;
      pos = pDoc->GetFirstViewPosition();
      while(pos!=NULL){
      pView = (CView*)pDoc->GetNextView(pos);
      if(pView->IsKindOf(RUNTIME_CLASS(CTESTView))){
      pView;}

 

반응형