CFileDialogST v1.0

摘要 CFileDialogST是使用SDK api实现的MFC CFileDialog类的重新实现。第一个有价值的功能是能够显示新的Windows 2000打开/保存通用对话框!CFileDialogST还包含一个函数,可以方便地显示用于选择文件夹的通用对话框。 这个类支持Unicode,并且与原始的MFC实现完全兼容。构造函数和函数具有相同的名称和参数列表,因此使用新的构造函数应该很容易。 CFileDialogST功能 cfiledialog (BOOL bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, LPCTSTR lpszFilter = NULL, CWnd* pParentWnd = NULL) 构造一个CFileDialogST对象。最常用的参数可以在参数列表中传递。隐藏,复制Code

// Parameters:
//  [IN]    bOpenFileDialog
//           Set to TRUE to construct a File Open dialog box or
//           FALSE to construct a File Save As dialog box.
//  [IN]    lpszDefExt
//           The default filename extension.
//           If the user does not include an extension in the Filename edit box,
//           the extension specified by lpszDefExt is automatically appended
//           to the filename.
//           If this parameter is NULL, no file extension is appended.
//  [IN]    lpszFileName
//           The initial filename that appears in the filename edit box.
//           If NULL, no filename initially appears
//  [IN]    dwFlags
//           A combination of one or more flags that allow 
//           you to customize the dialog box.
//  [IN]    lpszFilter
//           A series of string pairs that specify filters you can apply to the file.
//           If you specify file filters, only selected files will appear in the
//           Files list box.
//  [IN]    pParentWnd
//           Pointer to the owner window for the dialog box. Can be NULL.
//
CFileDialogST(BOOL bOpenFileDialog, LPCTSTR lpszDefExt, 
  LPCTSTR lpszFileName, DWORD dwFlags, 
  LPCTSTR lpszFilter, CWnd* pParentWnd)

CFileDialogST () 构造一个CFileDialogST对象。所有必需的参数必须通过手动访问m_ofn和m_bOpenFileDialog公共成员来初始化。 DoModal () 此函数显示文件选择对话框,并允许用户进行选择。m_ofn公共结构的所有必需字段必须被填充。这可以通过使用类构造函数或直接访问结构来完成。同样,公共变量m_bOpenFileDialog必须设置为TRUE以获得一个打开的对话框,或者设置为FALSE以获得一个保存对话框。隐藏,复制Code

// Return value:
//  IDOK
//    The user has selected a filename.
//  IDCANCEL
//    The user has closed the dialog without selecting any filename.
//
int DoModal()

装运箱GetPathName()常量 此函数返回所选文件的完整路径。隐藏,复制Code

// Return value:
//   A CString object containing the full path of the file.
//
CString GetPathName() const

装运箱GetFileName()常量 这个函数返回所选文件的文件名。隐藏,复制Code

// Return value:
//   A CString object containing the name of the file.
//
CString GetFileName() const

装运箱GetFileTitle()常量 这个函数返回所选文件的标题。隐藏,复制Code

// Return value:
//   A CString object containing the title of the file.
//
CString GetFileTitle() const

装运箱GetFileExt()常量 此函数返回所选文件的扩展名。隐藏,复制Code

// Return value:
//   A CString object containing the extension of the file.
//
CString GetFileExt() const

装运箱GetFileDir()常量 这个函数返回所选文件的目录(不带驱动器)。隐藏,复制Code

// Return value:
//   A CString object containing the directory (without drive) of the file.
//
CString GetFileDir() const

装运箱GetFileDrive()常量 这个函数返回所选文件的驱动器。隐藏,复制Code

// Return value:
//   A CString object containing the drive of the file.
//
CString GetFileDrive() const

位置GetStartPosition()常量 这个函数返回文件名列表中第一个元素的位置。隐藏,复制Code

// Return value:
//   A POSITION value that can be used for iteration.
//   NULL if the list is empty.
//
POSITION GetStartPosition() const

装运箱GetNextPathName (POSITION&pos)常量 此函数返回下一个选定文件的完整路径。隐藏,复制Code

// Parameters:
//   [IN]    pos
//            A reference to a POSITION value 
//            returned by a previous GetNextPathName 
//            or GetStartPosition function call. 
//            NULL if the end of the list has been reached.
//
// Return value:
//   A CString object containing the full path of the file.
//
CString GetNextPathName(POSITION& pos) const

LPCTSTR lpszStartPath = NULL, UINT ulFlags = BIF_RETURNFSANCESTORS | BIF_RETURNONLYFSDIRS, CWnd* pParentWnd = NULL 这个函数允许用户选择一个文件夹。隐藏,复制Code

// Parameters:
//   [IN]    lpszTitle
//             Address of a null-terminated string that is displayed above the 
//             tree view control in the dialog box. This string can be used to 
//             specify instructions to the user. Can be NULL.
//   [IN]    lpszStartPath
//             Address of a null-terminated string containing the initial folder
//             to open. Can be NULL.
//   [IN]    ulFlags
//             Flags specifying the options for the dialog box.
//   [IN]    pParentWnd
//             Pointer to the owner window for the dialog box. Can be NULL.
//
// Return value:
//   IDOK
//     The user has selected a folder and pressed OK. A call
//     to GetSelectedFolder() will return the selected folder.
//   IDCANCEL
//     The user has closed the dialog without selecting any folder.
//
int SelectFolder(LPCTSTR lpszTitle, LPCTSTR lpszStartPath, 
                               UINT ulFlags, CWnd* pParentWnd)

装运箱GetSelectedFolder()常量 这个函数通过调用SelectFolder返回用户选择的文件夹。隐藏,复制Code

// Return value:
//    A CString object containing the selected folder.
//    Without a previous call to SelectFolder this string can be empty or
//    reflect the last selected folder.
//
CString GetSelectedFolder() const

例子 演示应用程序CFileDialogST演示了如何打开文件(即使有多重选择)、询问要保存的文件名以及如何浏览文件夹。 想要在一个DLL中包含CFileDialogST ? CFileDialogST可以从DLL内部使用。你需要从你的DLL CFileDialogST导出。包括在您的DLL的项目,以下文件: FileDialogST.h FileDialogST.cpp 添加到您的DLL的项目设置,以下定义: _CMLHTDLL_NOLIB_ _CMLHTDLL_BUILDDLL_ 从FileDialogST。h,评论一下下面的句子:复制Code

#define _FILEDIALOGST_NODLL_

然后,根据生成的.lib文件更新各种#pragma注释(lib, "?? ")。 讲话 这种体系结构使得向类中添加其他特性成为可能。例如,可以添加对select-computer命令对话框的支持。如果有人实现了新特性,我很乐意在下一个CFileDialogST演示应用程序中包含他的代码。 本文转载于:http://www.diyabc.com/frontweb/news12444.html

posted @ 2020-08-11 10:56  Dincat  阅读(126)  评论(0编辑  收藏  举报