MDI获得任何一个视图或文档

来源:互联网 发布:linux chown 命令详解 编辑:程序博客网 时间:2024/05/15 04:01

      在网上找来半天还是没有一个能用的。后来自己终于解决了。

 

    

CWinApp* papp=AfxGetApp();

POSITION  pos = papp->GetFirstDocTemplatePosition();     //依次获得DocTemplate

if(pos==NULL)

return false;

CDocTemplate* pdoctemplate;

while(pos)            //依次测试doctemplate模板

{

pdoctemplate = papp->GetNextDocTemplate(pos);

POSITION  docpos;

docpos = pdoctemplate->GetFirstDocPosition();

if(docpos==NULL) continue;

CDocument *   pdoc = NULL;   

while(docpos)   //测试模板中的doc

{

pdoc = pdoctemplate->GetNextDoc(docpos);  

//Cview

POSITION   posview;

CView*   pView = NULL;   

posview = pdoc->GetFirstViewPosition();

if(posview==NULL) continue;

while(posview)     //测试doc对应的view

{

pView = pdoc->GetNextView(posview);  

if(pView->IsKindOf(RUNTIME_CLASS(CHsfsqView)))

            {

              m_statue=YANSHI;

  goto End;

            }

}

}

}