WTLVisual Studio 6Visual C++ 7.0Windows 2000Visual C++ 6.0Windows XPMFCIntermediateDevVisual StudioWindowsC++
WTL Hybrid Edit Control that Combines Edit Control and Button Control






4.25/5 (11 votes)
May 14, 2003
1 min read

56460

1433
A control that combines an edit control, and a browse button that brings up a file/folder browse dialog.
Introduction
Sometimes, when we need a user to select a file or folder or ODBC driver, we would have to create two controls, an edit control for entering the text, and a browse button that would bring up a dialog for actually choosing the file or folder or etc. So I thought why not combine the two controls into one. TheCWtlEditBrowserCtrl
class is the result. The
class definition and implementation are in the files
WtlEditBrowserCtrl.h and WtlEditBrowserCtrl.cpp which are
included in the demo project.
Using the Control
To use this control in your application:
- Add the WtlEditBrowserCtrl.h and WtlEditBrowserCtrl.cpp files to your project.
- Design the dialog and add the Edit control
- Add the WtlEditBrowserCtrl.h header file to your project
- Assign a
CWtlEditBrowserCtrl
to your editbox. - In
OnInitDialog()
, subclassCWtlEditBrowserCtrl
control to ID using theSubclassWindow
method.
#include "WtlEditBrowserCtrl.h" //... class CMainDlg : public CDialogImpl<CMainDlg> { BEGIN_MSG_MAP(CMainDlg) ... MESSAGE_HANDLER(WM_INITDIALOG, OnInitDialog) REFLECT_NOTIFICATIONS() END_MSG_MAP() ... LRESULT OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/); ... CWtlEditBrowserCtrl m_Path; ... }; //... LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { ... m_Path.SubclassWindow( ::GetDlgItem( m_hWnd, IDC_EDIT1 ) ); ... }
Requirements
You will require the WTL Libraries, these can be downloaded from the microsoft site.
Acknowledgements
I'd like to thank Pete Arends for his original controls :-
I'd also like to thank the others who have given feedback, made suggestions, and helped this become what it is today:
- Boris Kropivnitsky
- Andrew Fedoniouk ( http://www.terra-informatica.org/ )
- Sergei Zotin
Contacting the Author
Ilya Solnyshkin, E-mail: isolnyshkin@yahoo.com, Web: http://www.printsniffer.com/