For developers who use MFC this is a control which subclasses an edit control
to allow you to easily specify a folder. 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:
In addition the control integrates with the AutoCompletion functionality of Windows,
so that a drop down list appears underneath the edit control which allows the user
to quickly select a specific folder. The code 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.
The enclosed zip file contains source for
the routine and also includes a VC 2017 solution to build a small dialog based app
to demonstrate the routine.
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
Updates
v1.48 (2 April 2022)
- Updated copyright details.
- Updated the code to use C++ uniform initialization for all variable
declarations.
v1.47 (3 May 2020)
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.46 (14 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.45 (20 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
v1.44 (18 May 2019)
- Updated copyright details.
- Updated the code to clean compile on VC 2019
v1.43 (8 July 2018)
- Updated copyright details.
- Fixed a number of C++ core guidelines compiler warnings. These changes
mean that the code will now only compile on VC 2017 or later.
v1.42 (23 September 2017)
- Updated copyright details.
- Replaced CString::operator LPC*STR() calls throughout the codebase with
CString::GetString calls.
- Replaced NULL throughout the codebase with nullptr. This means that the
minimum requirement for the framework is now VC 2010.
- Reworked the code in CGetFolderControl::InitializeAutoComplete to
use ATL::CComPtr::CoCreateInstance.
- Reworked the CChooseDirDlg class to use IFileDialog interface.
- All the code has had SAL annotations added.
v1.41 (12 November 2015)
- Verified the code compiles cleanly on VC 2015.
- Updated the sample apps main icon.
- Updated copyright details.
v1.40 (23 December 2014)
- If the main edit control is now hidden, the buddy buttton is now also hidden.
The corollary of if the main edit control is now shown, then the buddy button
is now also shown. Thanks to Rene Laviolette for requesting this update.
v1.39 (1 March 2014)
- Updated copyright details.
- Updated MFC message maps in sample app and in DDXFile module to use C++
standard for pointers to member methods.
- Reworked DDX_FolderControl to use DDX_Control for most of its functionality
- Updated the code to clean compile on VC 2013 & 2012.
- Updated the code to clean compile using /analyze
v1.38 (10 September 2011)
- Updated copyright details.
- Verified code compiles cleanly on VC 2010
- Fixed an access violation bug in CDDXFolderModifyButton::PreTranslateMessage
if the IDS_DDXFOLDER_EDIT_TEXT string resource is not loaded
21 December 2008
- Minor update to documentation, screen captures and names of variables in
DDX / DDV functions.
v1.37 (18 December 2008)
- Updated copyright details.
- InitializeAutoComplete now returns a HRESULT instead of a BOOL
- DDV_FolderControlNotFile function has been renamed to DDV_FolderControlIsFolder
- Removed VC 6 style AppWizard comments from the code
- The code has now been updated to support VC 2005 or later only
- Code now compiles cleanly using Code Analysis (/analyze)
- Refactored the CChooseDirDlg codebase quite a bit
- Updated DDX_FolderControl code to be consistent with DDX_Control in VC 2008
v1.36 (21 November 2007)
- The code now uses the value 32 instead of the enum ACLO_FILESYSDIRS in the
call to IID_IACList2::SetOptions. This is because newer versions of the Windows
SDK make this value dependent on the setting of the _WIN32_IE preprocessor macros.
Thanks to Alexey Kuznetsov for reporting this issue.
v1.35 (19 November 2007)
- Minor update to display HRESULT's correctly.
- Minor tidy up to remove old style AppWizard comments
v1.34 (25 August 2006)
- Minor update to the name of one of the string resources used by DDXFolder
v1.33 (19 August 2006)
- Control now takes advantage of the AutoCompletion functionality (IAutoComplete
et al) built into Windows to improve the UI experience. If enabled then a drop
down list will appear underneath the edit control which allows the user to quickly
select a specific folder. The code uses the COM interfaces (IAutoComplete) to
AutoCompletion instead of the more simplified functionality provided by SHAutoComplete.
This allows the code to customize the auto completion UI so that only file system
folders are selectable.
v1.32 (11 August 2006)
- Reworked all the use of string resources. Now all the string resources used
by the control are all loaded in one single virtual function. In addition if
you do not want to use inheritance, all the strings can be customized via Get/Set
methods.
- Broke the DDV functionality into seperate discreet DDV functions
- The dialog control id of the edit button can now be specified via the SubclassEdit
and DDX_FilenameControl functions
v1.31 (29 July 2006)
- Initial enabled state of the edit control is now reflected into the edit
button when AddEditButton is called.
v1.30 (19 July 2006)
- Updated copyright details.
- Updated documentation to use the same style as the web site.
- Addition of a CCHOOSEDIRDLG_EXT_CLASS preprocessor macro to allow the code
to be easily added to an extension dll.
- Addition of a CDDXFOLDER_EXT_CLASS preprocessor macro to allow the code
to be easily added to an extension dll.
- Optimized CDDXFolderModifyButton constructor code
- Removed support for the old style directory picker dialog which used a modified
version of the File Open dialog.
- Changed the names of the constants used for DDV_FolderControl
- Added support for a DDXGETFOLDER_FOLDERMUSTEXIST flag
- Removed the GetFolder and SetFolder methods as they are not really required
- Verified code clean compiles in VC2005
v1.29 (9 January 2003)
- Updated copyright details.
- Changed a class name from "CModifyButton" to the better named "CDDXFileModifyButton".
- Enabled state of control is now reflected to buddy button edit control.
Thanks to "matro" for pointing out this problem.
- Made the "CGetFolderControl::Edit" virtual for easier customisation.
- Made all strings used by the classes easier to modify by making them virtual
methods of the class
- Made the "CGetFolderControl::AddEditButton" method virtual for
easier customisation.
v1.28 (24 May 2001)
- Fixed a problem with the Z-Order of the control being set incorrectly.
- Updated copyright message.
v1.27 (18 July 2000)
- Removed an unreferenced variable from the demo app module "testgetfolderDlg.cpp"
- Width of the edit button is now determined from the text which it displays.
v1.26 (17 May 2000)
- The width of the underlying edit control is now shrunk when the "..."
button is created. This makes layout of the control using the resource designer
a lot simpler.
v1.25 (14 May 2000)
- The "..." button now supports being tabbed into i.e. the WS_TABSTOP
style
v1.24 (11 December 1999)
- Cosmetic item where now a 1 pixel space is included between the edit control
and the "..." button.
v1.23 (3 April 1999)
- Fixed another resource compiler problem.
- Updated the copyright messages.
- General code tidy up.
7 February 1999
- Minor bug fix in choosedirdlg.cpp.
v1.22 (30 September 1998)
- Fixed a compiler problem in the rc file. I was accidentally shipping the
wrong resource.h file.
v1.21 (17 September 1998)
- Minor update to some code comments and the online documentation.
v1.2 (16 September 1998)
- Updated all the documentation to be HTML based as with my other shareware
/ freeware.
- Unicode enabled all the code and provision of Unicode build configurations.
- VC 5 workspace files provided now as standard
- Provision of a DDV function.
- General tidy up of the sample app including removing all the AppWizard generated
comments.
- All code now compiles cleanly at warning level 4.
- Replaced all TRACE0 calls with TRACE.
- Changed name of main function from DDX_GetFolder to DDX_FolderControl.
- Module name has been changed from ddxgetfolder to ddxfolder.
- Sample app now allows read only state of widget to be toggled.
- Addition of a DDX_FolderValue function.
- Change the ID's of the strings in the resource table which the code uses.
v1.1 (26 November 1997)
- Used internally by ddxgetfolder is another class which you may find helpful.
It's name is CChooseDirDlg which implements a standalone directory picker dialog
which can be used independently of the DDX/DDV functions.