CMFCEditBrowseCtrl Class
The CMFCEditBrowseCtrl class supports the edit browse control, which is an editable text box that optionally contains a browse button. When the user clicks the browse button, the control performs a custom action or displays a standard dialog box that contains a file browser or a folder browser.
class CMFCEditBrowseCtrl : public CEdit
Members
Public Constructors
Name |
Description |
---|---|
CMFCEditBrowseCtrl::CMFCEditBrowseCtrl |
Default constructor. |
CMFCEditBrowseCtrl::~CMFCEditBrowseCtrl |
Destructor. |
Public Methods
Name |
Description |
---|---|
Enables or disables (hides) the browse button. |
|
Enables the browse button and puts the edit browse control in file browse mode. |
|
Enables the browse button and puts the edit browse control in folder browse mode. |
|
Returns the current browse mode. |
|
Called by the framework after the edit browse control is updated with the result of a browse action. |
|
Called by the framework after the user clicks the browse button. |
|
Redraws the current edit browse control. |
|
Called by the framework to draw the browse button. |
|
CMFCEditBrowseCtrl::PreTranslateMessage |
Translates window messages before they are dispatched to the TranslateMessage and DispatchMessage Windows functions. For syntax and more information, see CWnd::PreTranslateMessage. |
Sets a custom image for the browse button. |
Remarks
Use an edit browse control to select a file or folder name. Optionally, use the control to perform a custom action such as to display a dialog box. You can display or not display the browse button, and you can apply a custom label or image on the button.
The browse mode of the edit browse control determines whether it displays a browse button and what action occurs when the button is clicked. For more information, see the GetMode method.
The CMFCEditBrowseCtrl class supports the following modes.
custom mode
A custom action is performed when the user clicks the browse button. For example, you can display an application-specific dialog box.file mode
A standard file selection dialog box is displayed when the user clicks the browse button.folder mode
A standard folder selection dialog box is displayed when the user clicks the browse button.
How-To: Specify an Edit Browse Control
Perform the following steps to incorporate an edit browse control in your application:
If you want to implement a custom browse mode, derive your own class from the CMFCEditBrowseCtrl class and then override the CMFCEditBrowseCtrl::OnBrowse method. In the overridden method, execute a custom browse action and update the edit browse control with the result.
Embed either the CMFCEditBrowseCtrl object or the derived edit browse control object into the parent window object.
If you use the Class Wizard to create a dialog box, add an edit control (CEdit) to the dialog box form. Also, add a variable to access the control in your header file. In your header file, change the type of the variable from CEdit to CMFCEditBrowseCtrl. The edit browse control will be created automatically. If you do not use the Class Wizard, add a CMFCEditBrowseCtrl variable to your header file and then call its Create method.
If you add an edit browse control to a dialog box, use the ClassWizard tool to set up data exchange.
Call the EnableFolderBrowseButton, EnableFileBrowseButton, or EnableBrowseButton method to set the browse mode and display the browse button. Call the GetMode method to obtain the current browse mode.
To provide a custom image for the browse button, call the SetBrowseButtonImage method or override the OnDrawBrowseButton method.
To remove the browse button from the edit browse control, call the EnableBrowseButton method with the bEnable parameter set to FALSE.
Inheritance Hierarchy
Example
The following example demonstrates how to use two methods in the CMFCEditBrowseCtrl class: EnableFolderBrowseButton and EnableFileBrowseButton. This example is part of the NewControls Sample: MFC Controls Demonstration Application.
CMFCEditBrowseCtrl m_wndFolderEdit;
CMFCEditBrowseCtrl m_wndFileEdit;
...
// enable the browse button and put the control in file browse mode
m_wndFolderEdit.EnableFolderBrowseButton();
// enable the browse button and put the control in the folder browse mode
m_wndFileEdit.EnableFileBrowseButton();
Requirements
Header: afxeditbrowsectrl.h