WTLSTLVisual Studio 6Visual C++ 7.0Windows 2000Visual C++ 6.0Windows XPIntermediateDevVisual StudioWindowsC++
WTL CFileTreeCtrl class






3.19/5 (13 votes)
Apr 23, 2003
1 min read

70893

2594
Implements a tree control similar to the left hand side of Windows Explorer
Credit and Acknowledgments
The original author of FileTree MFC control is PJ Naughter. This control and article can be found at http://www.codeproject.com/treectrl/filetree.asp
Overview
I needed a FileTree control to use in an ATL/WTL project and I decided to port MFC Control to WTL. The following ATL files contain the port:
- FileFind.h/FileFind.cpp - Contain the
CFileFind
class and implementation for WTL which performs local file searches - WtlFileTreeCtrl.h/WtlFileTreeCtrl.cpp - Contain the
CWtlFileTreeCtrl
class and implementation for WTL
How to use the control in your WTL App:
- Create a WTL Project
- Design the dialog and add the Tree control
- Add the WtlFileTreeCtrl.h header file to your project
- Assign a
CWtlFileTreeCtrl
to your tree. - In
OnInitDialog()
, subclass tree control (CWtlFileTreeCtrl
) to ID using theSubclassWindow
method. - In your dialog, don't forget to add the macro
REFLECT_NOTIFICATIONS
which allows theCWtlFileTreeCtrl
to get messages likeTVN_ITEMEXPANDING
.
#include "WtlFileTreeCtrl.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*/); ... CWtlFileTreeCtrl m_Tree; ... }; //... LRESULT CMainDlg::OnInitDialog(UINT /*uMsg*/, WPARAM /*wParam*/, LPARAM /*lParam*/, BOOL& /*bHandled*/) { ... m_Tree.SubclassWindow( ::GetDlgItem( m_hWnd, IDC_TREE1 ) ); ... }
Requirements
You will require the WTL Libraries, these can be downloaded from the microsoft site.
Note - This control uses the STL std::string
class and the STL std::vector
template class.
Contacting the Author
Ilya Solnyshkin, E-mail: isolnyshkin@yahoo.com, Web: http://www.printsniffer.com/