HOWTO: ????? ?????? ??????? ??? ?????? ??? ??? ????? MFC

?????? ????????? ?????? ?????????
???? ???????: 141921 - ??? ???????? ???? ????? ????? ??? ???????.
????? ???? | ?? ????

?? ??? ??????

??????

????????? ???? ?? ??????? ?????? ?? ??????? ???? Foundation ?? Microsoft "(MFC) ?? ????? ????? ????? ????? ??? ?????? ???? ???? ????? ??????? ?? ?? ??? ???????. ???? ????? ??? ????????? ??? ?? ???????? ??? ????? ?? ????? ???? ??????? ???? ?? ???? ????? ????.

?? ?????? ?????? ?????? ?????? ??????? ????? ?? ??? ????? ????. ???? ??? ??????? ????? ???? ??????? ?????? ????? ?????? ????? ??????? ??????? ?? ????? ???? ???????. ???? ?????? ??? ?????? ??????? ?? ?????? ?????? ?????? ??????? ??? ?? ???? ???????.

??????? ????

????? ???? ?????

???? ??????? ??????? ???? ????? ?????? ????? ??????? ?? ??? ????? ???? ?? ??????? SDI ?? MDI.

  1. ????? ????? ???? ????? ???? ????? ??? ????? ?????? ???????. ??? ????? ?????? ????? ??? ??? filterExt ?????? ?????? ?????? (??? ???? ??????? .aaa; .bbb). ?? ???? ?????? ???? ??????? ???? ???????:
       \nExts\nExts\nFiles (*.aaa; *.bbb)\n.aaa;.bbb\nExts.Doc\nExts Doc.
    					
  2. ?????? ??? ?? CMultiDocTemplate ??????? MDI ?? CSingleDocTemplate ????????? SDI. ????? ??? ????? ??? ??????? ?? ?????? ??? ????? ????? ??????? ?? ????? ?? InitInstance ??????. ?????? ??? ????? ????? ?????? ??????? ???? ??? ??????.
       CMyMultiDocTemplate::CMyMultiDocTemplate(
          UINT nIDResource, CRuntimeClass* pDocClass,
          CRuntimeClass* pFrameClass, CRuntimeClass* pViewClass ) :
          CMultiDocTemplate(nIDResource, pDocClass, pFrameClass, pViewClass)
          { };
    					
  3. ????? ???? GetDocString ?? ????? ??????? ????? ?? CMultiDocTemplate ?? CSingleDocTemplate ?? ?????? 2.
       BOOL CMyMultiDocTemplate::GetDocString(CString& rString,
                                enum DocStringIndex i) const
       {
            CString strTemp,strLeft,strRight;
            int nFindPos;
            AfxExtractSubString(strTemp, m_strDocStrings, (int)i);
    
            if(i == CDocTemplate::filterExt)  {
              nFindPos=strTemp.Find(';');
              if(-1 != nFindPos) {
                //string contains two extensions
                strLeft=strTemp.Left(nFindPos+1);
                strRight=strTemp.Right(lstrlen((const
                char*)strTemp)-nFindPos-1);
                strTemp=strLeft+strRight;
              }
            }
        rString = strTemp;
        return TRUE;
       }
    					
  4. ????? CMyMultiDocTemplate::MatchDocType ???? ??? ?????? ??? ??? ?????? ??????? ??? ??? ???.
       CDocTemplate::Confidence CMyMultiDocTemplate::MatchDocType(const
            char* pszPathName, CDocument*& rpDocMatch)
       {
            ASSERT(pszPathName != NULL);
            rpDocMatch = NULL;
    
            // go through all documents
            POSITION pos = GetFirstDocPosition();
            while (pos != NULL)
            {
               CDocument* pDoc = GetNextDoc(pos);
               if (pDoc->GetPathName() == pszPathName) {
                  // already open
                  rpDocMatch = pDoc;
                  return yesAlreadyOpen;
               }
            }  // end while
    
            // see if it matches either suffix
            CString strFilterExt;
            if (GetDocString(strFilterExt, CDocTemplate::filterExt) &&
              !strFilterExt.IsEmpty())
            {
               // see if extension matches
               ASSERT(strFilterExt[0] == '.');
               CString ext1,ext2;
               int nDot = CString(pszPathName).ReverseFind('.');
               const char* pszDot = nDot < 0 ? NULL : pszPathName + nDot;
    
               int nSemi = strFilterExt.Find(';');
               if(-1 != nSemi)   {
                 // string contains two extensions
                 ext1=strFilterExt.Left(nSemi);
                 ext2=strFilterExt.Mid(nSemi+2);
                 // check for a match against either extension
                 if (nDot >= 0 && (lstrcmpi(pszPathName+nDot, ext1) == 0
                     || lstrcmpi(pszPathName+nDot,ext2) ==0))
                   return yesAttemptNative; // extension matches
               }
               else
               { // string contains a single extension
                 if (nDot >= 0 && (lstrcmpi(pszPathName+nDot,
                     strFilterExt)==0))
                 return yesAttemptNative;  // extension matches
               }
            }
            return yesAttemptForeign; //unknown document type
       }
    					
  5. ???? ??? ? ??? ???? ?????? ???? ???? ?? DoSave ????? ???? ?? ????? ??????? ?????? CDocument. ???? ?????? ?? MFC ?????? CDocument::DoSave() ?? Mfc\Src\Doccore.cpp ????? ?? ??? ?????.

    ??????? ??? ??????:
            // append the default suffix if there is one
            CString strExt;
            if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
                !strExt.IsEmpty())
            {
               ASSERT(strExt[0] == '.');
               newName += strExt;
            }
    						
    ?? ??? ??????:
            // append the default suffix if there is one
            CString strExt;
            if (pTemplate->GetDocString(strExt, CDocTemplate::filterExt) &&
                !strExt.IsEmpty())
            {
              ASSERT(strExt[0] == '.');
    
              int nSemi;                       //added
              if(nSemi = strExt.Find(';'));    //added
              strExt = strExt.Left(nSemi);     //added
    
              newName += strExt;
            }
    						
    ????? ????? ???? ????????? ???????? ?????? ???? ????? ???? ??????? ??? "??? ????" ?????? ??? ????? ???? ????? ??? ????? ???????? ??????? ?? ????? ??????? ????? ??. ???? ????? ???????? ??? ??? ?????? ??? ??? ??? ?????? ???? ????? ?????? ??????? ?? ????? ???????.

    ?????? ????? ??? ??????? ???? ????????? ???????? ???????:
          CATCH_ALL(e)
          {
          TRACE0("Warning: failed to delete file after failed SaveAs.\n");
          DELETE_EXCEPTION(e);
          }
    						
    ??:
          CATCH_ALL(e)
          {
          TRACE0("Warning: failed to delete file after failed SaveAs.\n");
          e->Delete();     //modified
          }
    						
    ??? ?????? ???? ??? ??? ????? ??????? DELETE_EXCEPTION() ?? ??? ??????.
  6. (??????? 16 ?? ???) ??????? "????? ???" ?????? ??????? ????? OnFileSave ? OnFileSaveAs ?? ??? ????? ?? ???????. ??? ??? ??????? ??? ?? ????????? 16-?? ?? Visual C++ ? DoSave ?????? ??? ?????. ?????? ?? ???? ??????? ????????? ??? ?????? ?? ??????? ??? ?? Mfc\Src\Doccore.cpp ??? ??????? ?????. ??????? ??????? ?????? ?????? ??????? ?? DoSave ????? ?? ??????? ??? ??????. ?? ???? ??????? ?????? # ????? "io.h" ??? ??????? ?????? ????? ?????? _access.

?????

?????? ?????? ??????? ??????? ?? "????? ??????? ?? Microsoft:
198538DocMgrEx.exe ?????? ??????? ?????? Assoc w/1 ??? ?????

???????

???? ???????: 141921 - ????? ??? ??????: 16/?? ??????/1427 - ??????: 5.1
????? ???
  • Microsoft Foundation Class Library 4.2, ????? ?????? ??:
    • Microsoft Visual C++ 1.0 Professional Edition
    • Microsoft Visual C++ 1.5 Professional Edition
    • Microsoft Visual C++ 1.51
    • Microsoft Visual C++ 1.52 Professional Edition
    • Microsoft Visual C++ 2.0 Professional Edition
    • Microsoft Visual C++ 2.1
    • Microsoft Visual C++ 2.2
    • Microsoft Visual C++ 4.0 Standard Edition
????? ??????: 
kbmt kbdocview kbhowto KB141921 KbMtar
????? ????
???: ??? ????? ??? ?????? ???????? ?????? ????? ???? ????? ?????????? ????? ?? ????????? ?????? ????. ???? ???? ?????????? ???? ?? ???????? ???????? ?????? ????????? ????? ????????? ???????? ????? ???????? ?????? ?? ?????? ??? ?? ???????? ???????? ?? ????? ??????? ?????? ??? ??????? ?????? ??. ?????? ?? ???? ??? ??????? ???????? ????? ?? ???? ????? ?????? ??? ????? ??? ????? ??????? ?? ????? ?? ?????? ??? ??? ??????? ??????? ?? ????? ????? ????? ????? ?????. ?? ????? ???? ?????????? ??????? ??? ????? ?? ??????? ?? ????? ?????? ?? ??? ????? ?? ????? ??????? ?? ???????? ?? ??? ???????. ???? ???? ?????????? ???????? ??? ????? ?????? ??????? ??????
???? ??? ????? ??????? ?????? ??????????141921
????? ??????? ?? ????? ???? ?? ????? ???????
?? ????? ????? ?????? ???? ???? ???? ??? ??????? ??? ?? ? ?? ??? ??????? Microsoft ??? ????? ??? ??????? ????? ?????? ?????

????? ???????

 

Contact us for more help

Contact us for more help
Connect with Answer Desk for expert help.
Get more support from smallbusiness.support.microsoft.com