好像需要遍历文档模板
CDocTemplate::GetFirstDocPosition
CDocTemplate::GetNextDoc模板对应的第一个文档
CDocument::GetFirstViewPosition
CDocument::GetNextView
CDocument::GetDocTemplate到文档对应的第一个视图
CView::GetDocument
CView::GetParent
CView::GetParentFrameCFrameWnd::GetActiveView
CFrameWnd::GetActiveDocument

解决方案 »

  1.   

    该遍历的我都遍历了,源代码如下,请各位指正
    do{   
    if(bfind)
    break;
    CDocTemplate* doctemplate = pApp->GetNextDocTemplate(templatepos);
    POSITION docpos = doctemplate->GetFirstDocPosition();
    while(docpos)
    {   
    CDocument* pdoc = doctemplate->GetNextDoc(docpos);
    CString docPath = pdoc->GetPathName();
    CString docName = pdoc->GetTitle();
    MessageBox(selectedWindow + "\n" + docName);
    CMDIChildWnd* child = MDIGetActive();
    CString str;
    child->GetWindowText(str);
    if(docName == selectedWindow)
    {
    pos = pDoc->GetFirstViewPosition();
    CView* pFirstView = pDoc->GetNextView(pos);
    CMDIFrameWnd* pFrame=(CMDIFrameWnd*)AfxGetMainWnd();
    pFrame->MDIActivate(pFirstView);
    bfind=true;
    MessageBox("Actviated");
    break;   
    }   
    }   
    } while(pos != NULL);
      

  2.   

    //按标题(或者别的什么条件)找到需要的目标子窗口,激活
    CMDIFrameWnd* frmWnd=(CMDIFrameWnd*)theApp.m_pMainWnd;
    CMDIChildWnd* child = frmWnd->MDIGetActive();
    do
    {
    CString str;
    child->GetWindowText(str);
    if (str.Compare(<你搜索窗口用的凭据>)==0)
    {
    child->MDIActivate();        // or MDIActivate(child);
    break;
    } child = (CMDIChildWnd*) child->GetWindow(GW_HWNDNEXT);
    }
    while (child);