DDXFolder & CChooseDirDlg v1.22
For developers who use MFC this is a freeware DDX routine which subclasses an edit control to allow you to easily specify a directory (also known as a folder in Windows 95 parlance). When the edit control is correctly setup it will look like:
The button beside the edit control sports a tooltip when the button is over it and when the button is hit, the following dialog is displayed:
The caption of the dialog can be customized through the DDX routine. Another flag allows the developer to customize the dialog so that it uses the older style common dialog which looks like:
The routine is most useful when you want to specify a folder from somewhere in the user interface such as specifying a directory where a bunch of output files will be placed..
Features |
History |
Usage |
API Reference |
Contacting the Author |
To use ddxfolder in your project simply
include ddxfolder.cpp, dlgdir.cpp, the 3 string resources and the dialog resource
"FILEOPENORD" from the test application in your application. Then #include
ddxfolder.h in which ever of your modules requires it and make the appropriate calls.
Included is a simple dialog based application which shows how to use it. Basically all you
need to do is add to your DoDataExchange function as follows:
v1.1 (
v1.2 (16th September 1998)
v1.21 (17th September 1998)
The following functions are provided:
CChooseDirDlg::GetDirectory
DDX_FolderControl
DDX_FolderValue
DDV_FolderControl
BOOL GetDirectory(CString& sDir, CWnd* pWndParent, BOOL bOldStyleDialog, const CString& sTitle);
Return Value
TRUE if the applet was successfully displayed otherwise FALSE.
Parameters
sDir is used to set the initial directory and upon return contains the newly selected directory.
pWndParent is the parent window to use.
bOldStyleDialog allows you to use the older pre Windows 4 style dialog.
sTitle is the title to use on the dialog.
Remarks
Internally this function is called when you click on the "..." button on the UI. You are free to use this independently of the DDX / DDV code to call up a directory picker dialog in your own code.
DDX_FolderControl
void DDX_FolderControl(CDataExchange* pDX, int nIDC, CGetFolderControl& rCGetFolderControl, DWORD dwFlags, const CString& sDialogTitle);
Parameters
pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.
nIDC is the dialog ID of the edit control to subclass.
rCGetFolderControl will contain upon return the window control which manages the compound edit and button controls.
dwFlags is a combination of the bit values to customize the display of the dialog. See ddxgetfolder.h for all the allowable values.
sDialogTitle is the caption to use for the directory picker dialog.
Remarks
Associates an existing edit control with dialog ID nIDC to a compound directory picker control. Normally you would calls to this function in your dialog class's DoDataExchange member function.
void DDX_FolderControl(CDataExchange* pDX, CGetFolderControl& rCGetFolderControl, CString& sFolder);
Parameters
pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.
rCGetFolderControl is the folder control to get or set the directory for.
sFolder is the actual folder to get or set into the control depending on the direction of data exchange occuring .
void DDV_FolderControl(CDataExchange* pDX, CGetFolderControl& rCGetFolderControl, DWORD dwFlags);
Parameters
pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.
rCGetFolderControl is the folder control to get or set the directory for.
dwFlags
is the flags to use to perform validation. Currently only GFLDR_FOLDER_MUST_EXIST is supported which requires you to enter a valid directory / folder. Normally you would use this flag except in the case where creating the directory may be required such as in an install program.
PJ Naughter
Email: pjn@indigo.ie
Web: http://indigo.ie/~pjn
30th September 1998