好像需要遍历文档模板
CDocTemplate::GetFirstDocPosition
CDocTemplate::GetNextDoc模板对应的第一个文档
CDocument::GetFirstViewPosition
CDocument::GetNextView
CDocument::GetDocTemplate到文档对应的第一个视图
CView::GetDocument
CView::GetParent
CView::GetParentFrameCFrameWnd::GetActiveView
CFrameWnd::GetActiveDocument
CDocTemplate::GetFirstDocPosition
CDocTemplate::GetNextDoc模板对应的第一个文档
CDocument::GetFirstViewPosition
CDocument::GetNextView
CDocument::GetDocTemplate到文档对应的第一个视图
CView::GetDocument
CView::GetParent
CView::GetParentFrameCFrameWnd::GetActiveView
CFrameWnd::GetActiveDocument
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);
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);