CDocTemplate::Confidence CDocTemplate::MatchDocType(LPCTSTR lpszPathName, CDocument*& rpDocMatch) { ASSERT(lpszPathName != NULL); rpDocMatch = NULL; // go through all documents POSITION pos = GetFirstDocPosition(); while (pos != NULL) { CDocument* pDoc = GetNextDoc(pos); if (AfxComparePath(pDoc->GetPathName(), lpszPathName)) { // already open rpDocMatch = pDoc; return yesAlreadyOpen; } } // see if it matches our default suffix CString strFilterExt; if (GetDocString(strFilterExt, CDocTemplate::filterExt) && !strFilterExt.IsEmpty()) { // see if extension matches ASSERT(strFilterExt[0] == '.'); LPCTSTR lpszDot = _tcsrchr(lpszPathName, '.'); if (lpszDot != NULL && lstrcmpi(lpszDot, strFilterExt) == 0) return yesAttemptNative; // extension matches, looks like ours } // otherwise we will guess it may work return yesAttemptForeign; }
void CSingleDocTemplate::SetDefaultTitle(CDocument* pDocument) { CString strDocName; if (!GetDocString(strDocName, CDocTemplate::docName) || strDocName.IsEmpty()) { // use generic 'untitled' VERIFY(strDocName.LoadString(AFX_IDS_UNTITLED)); } pDocument->SetTitle(strDocName); }
void CDocTemplateEx::LoadStdProfileSettings(UINT nMaxMRU) { ASSERT_VALID(this); ASSERT(m_pRecentFileList == NULL); CString FileEntry = _T("File%d"); CString FileSection; GetDocString(FileSection, CDocTemplate::docName); if (nMaxMRU != 0) { // create file MRU since nMaxMRU not zero m_pRecentFileList = new CRecentFileList(0, FileSection, FileEntry, nMaxMRU); m_pRecentFileList->ReadList(); } }