从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 );

你可能感兴趣的:(frame)