MFC多文档中如何即时获取当前文档的指针?

2024-12-30 03:00:01
推荐回答(1个)
回答1:

CMDIFrameWnd *pFrame = (CMDIFrameWnd*)AfxGetApp()-> m_pMainWnd;
// 获取活动的子框架
CMDIChildWnd *pChild = (CMDIChildWnd *) pFrame-> GetActiveFrame();
// 或者 CMDIChildWnd *pChild = pFrame-> MDIGetActive();
// 获取当前活动的视图指针
CMyView *pView = (CMyView *) pChild-> GetActiveView();
CmyDocument* pDoc =(CmyDocument*) pView-> GetDocumnet()