从CMainFrame中获取文档类指针
有时候可能需要在CMainFrame::OnCreate中调用文档类指针,以获取某些数据,
下面的代码用于从框架类获取文档类指针:
下面的代码用于从框架类获取文档类指针:
CMyTestApp *pApp = (CMyTestApp*) AfxGetApp();
POSITION posDT = pApp->GetFirstDocTemplatePosition();
CDocTemplate *pDocTemplate = pApp->GetNextDocTemplate( posDT );
POSITION posDoc = pDocTemplate->GetFirstDocPosition();
CMyTestDoc *pDocument = (CMyTestDoc*) pDocTemplate->GetNextDoc( posDoc );