CFileDialogImpl Class

class CFileDialogImpl

This class represents the base class for SFL's common file dialog boxes. You set up the common file dialog box with a starting path, a default file extension, and file extension filters and then show the dialog box.

The dialog box shows a tree control allowing the user to find the file.

CFileDialogImpl includes the following member functions  CFileDialogImpl,  DoModal,  GetFileDialogWindow.  GetFileName,  GetFileTitle,  GetFilePath,  GetFolderIDList,  GetFolderPath,  GetSpec,  SetControlText,  SetDefExt,  GetReadOnlyPref,  HideControl, and  EndDialog

Defined in: CommonDialogs.h

Class Template Arguments

_Derived

The ultimately-derived class

Comments

SFL contains implementations of the common file management dialog boxes. Both  COpenFileDialog and CSaveAsFileDialog inherit from CFileDialogImpl. CFileDialogImpl serves as the base class for SFL's common file dialog boxes. CFileDialogImpl Inherits from ATL's CDialogImplBase and so has the normal dialog box functionality. CFileDialogImpl has a member variable of type OPENFILENAME named m_ofn, which the file open and file save dialog boxes use to pass to the file dialog API functions. In addition, CFileDialogImpl has a boolean member variable named m_bOpenFileDialog. DoModal simply checks this flag to decide whether to call GetOpenFileName or GetSaveFileName API functions.

Class Members

CFileDialogImpl( bool bOpenFileDialog, LPCTSTR lpszDefExt = NULL, LPCTSTR lpszFilter = NULL, LPCTSTR lpszFileName = NULL, DWORD dwFlags = OFN_HIDEREADONLY | OFN_OVERWRITEPROMPT, #if (_WIN32_WINNT >= 0x0500) DWORD dwExFlags = OFN_EX_NOPLACESBAR, #else DWORD dwExFlags = 0, #endif HWND hWndParent = NULL )

Constructor

int  DoModal( HWND hWndParent = ::GetActiveWindow() )

Invoke the dialog box

CWindow  GetFileDialogWindow() const

Get the dialog's window handle

LPCTSTR  GetFileName() const

Get the selected file name

LPCTSTR  GetFileTitle() const

Get the selected file title

int  GetFilePath(LPTSTR lpstrFilePath, int nLength) const

Get the entire path for the selected file

int  GetFolderIDList(LPVOID lpBuff, int nLength) const

Get the IDs of the folders

int  GetFolderPath(LPTSTR lpstrFolderPath, int nLength) const

Get the selected folder's path

int  GetSpec(LPTSTR lpstrSpec, int nLength) const

Retrieves the file name (not including the path) of the currently selected file

void  SetControlText(int nCtrlID, LPCTSTR lpstrText)

Set the text for a specific control

void  SetDefExt(LPCTSTR lpstrExt)

Set the default extension

BOOL  GetReadOnlyPref() const

Find out if the files include read-only files.

void  HideControl(int nCtrlID)

Hide a specific control

BOOL  EndDialog(int nRetCode = 0)

End the dialog