假设建立MFC工程名称为 MyTest;
//首先找到当前工程主框架
CMainFrame *pMainWnd = (CMainFrame*)AfxGetApp()->m_pMainWnd;
//有主框架找到当前活动子框架
CMDIChildWnd *pChild = (CMDIChildWnd *) pMainWnd->GetActiveFrame();
//由活动子框架,找到当前活动视图
CMyTestView *pView = (CMyTestView*) pChild->GetActiveView();
//当前活动是与文档通信函数GetDocument()
CMyTestDoc *pDoc=(CMyTestDoc *)pChild->GetActiveDocument();
或者
CMyTestDoc *pDoc=pView->GetDocument();