DDXFolder & CChooseDirDlg v1.48

For developers who use MFC this is a freeware control which subclasses an edit control to allow you to easily specify a directory/folder. When the edit control is correctly setup it will look like:

DDXFolder Sample 1

 

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:

DDXFolder Sample 2

 

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..

 

 

 

Features
Copyright
History
Usage
API Reference
Contacting the Author

 

 

 

Features

 

 

 

Copyright

 

 

 

Usage

void CTestgetfolderDlg::DoDataExchange(CDataExchange* pDX)
{
  //Let the base class do its thing
  CDialog::DoDataExchange(pDX);
 
  DDX_FolderControl(pDX, IDC_FOLDER, m_ctrlGetFolder);
}

 

 

 

History

v1.48 (2 April 2022)

v1.47 (3 May 2020)

v1.46 (14 March 2020)

v1.45 (20 December 2019)

v1.44 (18 May 2019)

v1.43 (8 July 2018)

v1.42 (23 September 2017)

v1.41 (12 November 2015)

v1.40 (23 December 2014)

v1.39 (1 March 2014)

v1.38 (10 September 2011)

21 December 2008

v1.37 (18 December 2008)

v1.36 (21 November 2007)

v1.35 (19 November 2007)

v1.34 (25 August 2006)

v1.33 (19 August 2006)

v1.32 (11 August 2006)

v1.31 (29 July 2006)

v1.30 (19 July 2006)

v1.29 (9 January 2003)

v1.28 (24 May 2001)

v1.27 (18 July 2000)

v1.26 (17 May 2000)

v1.25 (14 May 2000)

v1.23 (3 April 1999)

7 February 1999

v1.22 (30 September 1998)

v1.21 (17 September 1998)

v1.2 (16 September 1998)

v1.1 (26 November 1997)

 

 

 

API Reference

The following functions are provided:

CChooseDirDlg::DoModal
DDX_FolderControl
DDX_FolderValue
DDV_FolderControlIsFolder

DDV_FolderControlMustExist
DDV_FolderControlOverwritePrompt
DDV_FolderNotEmpty

 

CChooseDirDlg::DoModal

HRESULT DoModal(CString& sDir);

Return Value

A standard COM error code. S_OK if successful.

Parameters

sDir is used to set the initial directory and upon return contains the newly selected directory.

Remarks

Internally this function is called when you click on the "..." button on the UI. You are free to use this class independently of the DDX / DDV code to call up a directory picker dialog in your own code.

 

DDX_FolderControl

BOOL DDX_FolderControl(CDataExchange* pDX, int nIDC, CGetFolderControl& rControl, UINT nModifyButton = 0xFFFFFFFF);

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.

rControl will contain upon return the window control which manages the compound edit and button controls.

nModifyButtonID is a control id of the modify button.

Remarks

Associates an existing edit control with dialog ID nIDC to a compound folder picker control. Normally you would calls to this function in your dialog class's DoDataExchange member function. The function returns TRUE if the setup of the edit control succeeded otherwise FALSE is returned.

 

DDX_FolderValue

void DDX_FolderValue(CDataExchange* pDX, CGetFolderControl& rControl, CString& sFolder);

Parameters

pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.

rControl 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 occurring .

 

DDV_FolderControlIsFolder

void DDV_FolderControlIsFolder(CDataExchange* pDX, const CGetFolderControl& rControl, UINT nFailureResourceID, UINT nHelpID = 0xFFFFFFFF);

Parameters

pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.

rControl is the folder control to validate for.

nFailureResourceID is the resource id of the string which will be displayed as a failure message.

nHelpID is the help context ID for the message.

Remarks

This DDV function ensures that the value selected specifies a folder (as opposed to a file).

 

DDV_FolderControlMustExist

void DDV_FolderControlMustExist(CDataExchange* pDX, const CGetFolderControl& rControl, UINT nFailureResourceID, UINT nHelpID = 0xFFFFFFFF);

Parameters

pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.

rControl is the folder control to validate for.

nFailureResourceID is the resource id of the string which will be displayed as a failure message.

nHelpID is the help context ID for the message.

Remarks

This DDV function ensures that the value selected specifies an existing folder.

 

DDV_FolderControlOverwritePrompt

void DDV_FolderControlOverwritePrompt(CDataExchange* pDX, CGetFolderControl& rControl, UINT nHelpID = 0xFFFFFFFF);

Parameters

pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.

rControl is the folder control to validate for.

nHelpID is the help context ID for the message.

Remarks

This DDV function prompts the user if an overwrite is allowable if the folder already exists. Validation fails if the end user selects No to the message.

 

 

DDV_FolderControlNotEmpty

void DDV_FolderControlNotEmpty(CDataExchange* pDX, const CGetFolderControl& rControl, UINT nFailureResourceID, UINT nHelpID = 0xFFFFFFFF);

Parameters

pDX is the usual CDataExchange object which will be passed into your DoDataExchange function.

rControl is the folder control to validate for.

nFailureResourceID is the resource id of the string which will be displayed as a failure message.

nHelpID is the help context ID for the message.

Remarks

This DDV function ensures that the value selected is not an empty string.

 

 

 

Contacting the Author

PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
2 April 2022