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

posted @ 2008-01-18 15:00  glimix  阅读(485)  评论(0编辑  收藏  举报