DDXFile v1.34

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

DDXFile Sample 1

 

The button beside the edit control sports a tooltip when the button is over it and when the button is hit a modified version of the common file open dialog is displayed to allow the user to select a filename as:

DDXFile Sample 2

 

Both the caption and file extension filter can be customized. 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 file. Other methods allow the developer to customize whether overwrites are notified to the user and only existing files allowed. The code is most useful when you want to specify a filename from somewhere in the user interface but don't necessarily want to "Open" or "Save" a file. Note that the default button has the text "OK" as opposed to "Save" or "Open" which is what you normally would get with the standard common file dialogs.

 

Features
Copyright
History
Usage
API Reference
Contacting the Author

 

 

 

Features

 

 

 

Copyright

 

 

 

Usage

void CTestgetfileDlg::DoDataExchange(CDataExchange* pDX)
{
  //Let the base class do its thing
  __super::DoDataExchange(pDX);

  DDX_FilenameControl(pDX, IDC_FILENAME, m_ctrlGetFilename);
}

 

 

 

History

v1.34 (1 April 2022)

v1.33 (3 May 2020)

v1.32 (14 March 2020)

v1.31 (21 December 2019)

v1.30 (18 May 2019)

v1.29 (9 July 2018)

v1.28 (24 September 2017)

v1.27 (11 November 2015)

v1.26 (23 December 2014)

v1.25 (1 March 2014)

v1.24 (10 September 2011)

v1.23 (21 December 2008)

v1.22 (19 November 2007)

v1.21 (20 August 2006)

v1.20 (11 August 2006)

v1.19 (29 July 2006)

v1.18 (19 July 2006)

10 January 2003

v1.17 (9 January 2003)

v1.16 (27 December 2001)

v1.15 (24 May 2001)

v1.14 (18 July 2000)

v1.13 (17 May 2000)

v1.12 (14 May 2000)

v1.11 (11 December 1999)

v1.1 (17 September 1998)

 

 

 

API Reference

The following functions are provided:

DDX_FilenameControl
DDX_FilenameValue
DDV_FilenameControlNotFolder

DDV_FilenameControlMustFile
DDV_FilenameControlOverwritePrompt
DDV_FilenameControlNotEmpty

 

DDX_FilenameControl

bool DDX_FilenameControl(CDataExchange* pDX, int nIDC, CGetFilenameControl& rControl, UINT nModifyButtonID = 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 filename 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_FilenameValue

void DDX_FilenameControl(CDataExchange* pDX, CGetFilenameControl& rControl, CString& sFile);

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

sFile is the actual file to get or set into the control depending on the direction of data exchange occurring.

Remarks

Gets the actual string value which the control contains.

 

DDV_FilenameControlNotFolder

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

Parameters

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

rControl is the filename 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 does not specify a folder.

 

DDV_FilenameControlMustExist

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

Parameters

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

rControl is the filename 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 file.

 

DDV_FilenameControlOverwritePrompt

void DDV_FilenameControlOverwritePrompt(CDataExchange* pDX, CGetFilenameControl& rControl, UINT nHelpID = 0xFFFFFFFF);

Parameters

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

rControl is the filename 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 file already exists. Validation fails if the end user selects No to the message.

 

 

DDV_FilenameControlNotEmpty

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

Parameters

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

rControl is the filename 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
1 April 2022