CFileDialog::CFileDialog CFileDialog( BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL ); BOOL bOpenFileDialog该参数为指定true是Open,false是Save as 对话框。 LPCTSTR lpszDefExt添加到没有扩展名文件上的扩展名 LPCTSTR lpszFileName应该初始选定的文件名 DWORD dwFlags 自定义标志,当要进行多选的时候添加OFN_ALLOWMULTISELECT LPCTSTR lpszFilterFile of type中的过滤参数例如: CString lpszFilter="位图(*.bmp)|*.bmp|\ 全部文件(*.*)|*.*||"; CWnd* pParentWnd父窗口的指针。 CFileDialog::GetFileName 得到打开文件的名字 For example, GetFileName will return "TEXT.DAT" for the file C:\FILES\TEXT.DAT. CFileDialog::GetFileTitle 得到打开文件的标题,不含扩展名。 For example, GetFileTitle will return "TEXT" for the file C:\FILES\TEXT.DAT. CFileDialog::GetFileExt 得到打开文件的扩展名。 For example, if the name of the file entered is DATA.TXT, GetFileExt returns "TXT". CFileDialog::GetPathName 得到打开文件的路径名 For example, GetPathName will return "C:\FILES\TEXT.DAT" for the file C:\FILES\TEXT.DAT. CFileDialog::GetStartPosition得到列表中第一个文件路径的位置。 该函数使用时候,构造函数中的dwFlags必须选定OFN_ALLOWMULTISELECT CFileDialog::GetNextPathName根据选择的位置返回该文件的路径名 For example, GetNextPathName will return "C:\FILES\TEXT.DAT" for the file C:\FILES\TEXT.DAT. CFileDialog::OnShareViolation当用户发生共享时,该函数返回共享警告或提示。一般系统会自动提示 virtual UINT OnShareViolation( LPCTSTR lpszPathName ); If you want to disable share violation checking, use the bitwise OR operator to combine the flag OFN_SHAREAWARE with m_ofn.Flags. CFileDialog::OnFileNameOK使得在对话框输入的文件名生效。一般系统会自动提示

评论