遍历文档模板、文档和视图

来源:互联网 发布:js 判断ie浏览器 编辑:程序博客网 时间:2024/05/17 02:13

在网上摘抄的一段代码,它完成遍历文档模板、文档和视图的功能

CMyApp *pMyApp = (CMyApp*)AfxGetApp(); //得到应用程序指针
POSITION p = pMyApp->GetFirstDocTemplatePosition();//得到第1个文档模板
while (p != NULL) //遍历文档模板
{
 CDocTemplate *pDocTemplate = pMyApp->GetNextDocTemplate(p);
 POSITION p1 = pDocTemplate->GetFirstDocPosition();//得到文档模板对应的第1个文档
 while (p1 != NULL) //遍历文档模板对应的文档
 {
  CDocument *pDocument = pDocTemplate->GetNextDoc(p1);
  POSITION p2 = pDocument->GetFirstViewPosition(); //得到文档对应的第1个视图
  while (p2 != NULL) //遍历文档对应的视图
  {
   CView *pView = pDocument->GetNextView(p2);
  }
 }

另:今天调试的时候才明白,分割视图中,视图的父窗口是CSplitterWnd,父窗口的父窗口才是子框架

原创粉丝点击