FindOpenDocument - if the C++ framework has a document with this name open, then return a pointer to it, else NULL.
| 74 | // FindOpenDocument - if the C++ framework has a document with this name open, |
| 75 | // then return a pointer to it, else NULL. |
| 76 | CDocument *CProtectedWinApp::FindOpenDocument(const TCHAR *lpszFileName) |
| 77 | { |
| 78 | POSITION posTempl = m_pDocManager->GetFirstDocTemplatePosition(); |
| 79 | CDocument* pOpenDocument = NULL; |
| 80 | |
| 81 | TCHAR szPath[_MAX_PATH]; |
| 82 | if (!AfxFullPath(szPath, lpszFileName)) |
| 83 | _tcscpy(szPath, lpszFileName); |
| 84 | |
| 85 | while (posTempl) { |
| 86 | CDocTemplate* pTemplate = m_pDocManager->GetNextDocTemplate(posTempl); |
| 87 | ASSERT(pTemplate->IsKindOf(RUNTIME_CLASS(CDocTemplate))); |
| 88 | // go through all documents |
| 89 | POSITION posDoc = pTemplate->GetFirstDocPosition(); |
| 90 | while (posDoc) { |
| 91 | CDocument* pDoc = pTemplate->GetNextDoc(posDoc); |
| 92 | if (lstrcmpi(pDoc->GetPathName(), szPath) == 0) |
| 93 | return pDoc; |
| 94 | } |
| 95 | } |
| 96 | return NULL; |
| 97 | } |
| 98 | |
| 99 | CProtectedDocManager *CProtectedWinApp::GetDocManager() |
| 100 | { |
no test coverage detected