请教各位大哥大姐:
   小弟我刚学VC不久,有件事想问问大家.我用MFC向导生成了一个单文档的程序,其中我的视类是从CEditView里面继承过来的.当我写了几行字符串后,我用了向导自动生成的"保存为"这一菜单项,保存文件时,我想把所保存的文件路径记下来.放在一个变量里.这个问题我查了好多天都不知道该怎么解决.哪位大哥大姐能帮帮我.谢谢

解决方案 »

  1.   

    lz,在classview里选择doc那个类,右键菜单选择Add Virtual Function,出来的对话框里增加OnSaveDocument,然后系统会自动在你的doc类里增加重载函数OnSaveDocument(LPCTSTR lpszPathName),好了,这个参数lpszPathName你知道是什么了吧
      

  2.   

    Call this function to get the fully qualified path of the document's disk file.
    const CString& GetPathName( ) const;
    The document's fully qualified path. This string is empty if the document has not been saved or does not have a disk file associated with it.
      

  3.   

    你可自处理ID_FILE_SAVE命消息void CMyDlg::OnFileSave()
    {
      char szFilters[]="MyType Files (*.my)|*.my|All Files (*.*)|*.*||";  CFileDialog dlg(FALSE, NULL, NULL, NULL, OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT,
                      szFilters, this);
      if(dlg.DoModal() == IDOK)
      {
         CString pathName = fileDlg.GetPathName();
         // 文件路径就保存在pathName中
      }
      
    }
      

  4.   

    在CxxxDoc::Serialize(CArchive& ar)里得到:AfxMessageBox(ar.GetFile()->GetFilePath());