不重载OnFileOpen 得到文件路径

来源:百度知道 编辑:UC知道 时间:2024/06/08 10:06:45
我用MFC创建了SDI,其中视类继承的是CEditView,为的是直接实现记事本功能,现在我想得到打开文件的路径,其中一个方法是重载OnFileOpen,利用CFileDlg类的GetPathName()。如果我不重载OnFileOpen,请问可否直接得到已打开文件的路径?
网上查到说可以直接用lpszPathName就是当前文件的路径,我在View类里面用这个有错,“undeclared identifier”

先定义:CFileDialog 对象 fd
fd.GetPathName();

CDocument::GetPathName See Also
CDocument Overview | Class Members | Hierarchy Chart | CDocument::SetPathName
Call this function to get the fully qualified path of the document's disk file.

const CString& GetPathName( ) const;
Return Value
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.

-------------------------------------------
CDocument::GetTitle See Also
CDocument Overview | Class Members | Hierarchy Chart | CDocument::SetTitle
Call this function to get the document's title, which is usually derived from the document's filename.

const CString& GetTitle( ) const;
Return Value
The document's title.

--------------------------------
重载下面的函数
BOOL CEditviewDoc::OnOpenDocument(LPCTSTR lpszPathName)
{
if (!CDocument