CFileTreeCtrl v1.62
CFileTreeCtrl provides an MFC class which provides a tree control similar to
the left hand side of Windows Explorer with the major addition that you can also
show files in it.

Features
- CFileTreeCtrl is derived from CTreeCtrl and can be created using the same
mechanisms.
- Uses the system image list for the icons for folders and files.
- Can have multiple instances of the control active at one time.
- Optionally allows files to be displayed as well as folders.
- Integrates with the shell to allow the file to be "opened" and
its properties page to be displayed.
- Provides for deletion and moving to the recycle bin. Message boxes used
are the same as those provided in Windows Explorer.
- Supports drag & drop and auto scrolling while dragging.
- Standard MFC DDX functions are provided to easily integrate with dialog
based apps.
- Supports in place renaming of items.
- Provides a full set of keyboard accelerators similar to Windows Explorer.
- Unicode enabled and all code compiles cleanly at warning level 4.
- Can be used in a dialog resource or a CView derived class.
Usage
- To use CFileTreeCtrl, include "FileTreeCtrl.cpp / h" in your project and
#include "FileTreeCtrl.h" in the module you want to instantiate it in. You can
use the usual MFC ways of hooking up the class. If you are using the class in
a dialog resource, then you can use the DDX function provided. You can also
create the control dynamically by calling its parent classes CTreeCtrl::Create
method, in this case you will need to call the PopulateTree yourself to display
the tree contents. To allow the control to allow in place editing of files /
folders, just include the standard TVS_EDITLABELS tree control window style.
- You will also need to copy across the IDR_TREEFILECTRL_* resources from
either of the sample apps provided with the code.
- Note that as of v1.58, the code is now for Visual C++ 2017 or later.
- Please note that you may have difficulties when using the class in a CDialogBar
derived class. As reported by Don Woodward: I put one of these in my CDialogBar
derived class and because of CControlBar's WindowProc coupled with you doing
this everywhere:
return FALSE; //Allow the message to be reflected again
things were going haywire.
....
My solution was to do this in my CDialogBar
class:
LRESULT MyDialogBar::WindowProc(UINT nMsg, WPARAM wParam, LPARAM
lParam)
{
if ((WM_NOTIFY == nMsg) && (((NMHDR*)lParam)->idFrom
== IDC_MY_TREE_CONTROL_ID))
{ // a WM_NOTIFY coming from our tree
control; use CWnd's WindowProc cause CDialogBar's will dispatch to our tree
control twice
return CWnd::WindowProc(nMsg, wParam, lParam);
}
return CDialogBar::WindowProc(nMsg, wParam, lParam);
}
Copyright
- You are allowed to include the source code in any product (commercial, shareware,
freeware or otherwise) when your product is released in binary form.
- You are allowed to modify the source code in any way you want except you
cannot modify the copyright details at the top of each module.
- If you want to distribute source code with your application, then you are
only allowed to distribute versions released by the author. This is to maintain
a single distribution point for the source code.
History
v1.62 (4 May 2020)
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.61 (15 March 2020)
- Updated copyright details.
- Fixed more Clang-Tidy static code analysis warnings in the code.
v1.60 (21 December 2019)
- Fixed various Clang-Tidy static code analysis warnings in the code.
- Updated initialization of various structs to use C++ 11 list
initialization
v1.59 (29 September 2019)
- Fixed a number of compiler warnings when the code is compiled with VS
2019 Preview
v1.58 (21 July 2019)
v1.57 (6 June 2016)
- Updated copyright details.
- Updated the sample project settings to more modern default values.
- Updated the code to clean compile on VC 2013 - VC 2015.
- Fixed a security issue in the sample app in the use of LoadLibrary on
"UXTheme.dll".
- Updated the dialog based sample app's main icon.
- The code now gracefully handles the situation where calls to
SHGetDesktopFolder or SHGetMalloc fail during control initialization.
- Fixed a bug where you could not drag an item to a network share.
- The code now shows shortcuts using an overlay mask. This is similar to
how shared folders are optionally already shown by the control with an
overlay mask.
- Fixed a issue where the Current User Folder was not showing with a
customized icon.
- Fixed an issue in the sample app where the control would fail to
show some icons initially due to the fact that the sample app was not
initializing OLE on startup.
- Added SAL annotations to all the code
v1.56 (7 April 2013)
- Minor update to the code in DisplayNetworkComputer method.
- Fixed a spelling mistake in EnumNetwork method.
v1.55 (6 April 2013)
- Updated copyright details.
- Updated the code to compile cleanly on VC 2010 and later
- Reworked CFileTreeCtrl::AddMultipleFileNameMasks to use CString::Tokenize
- Removed old Win9x code path from CShareEnumerator class.
- Reworked the CSystemImageList class to remove the defunct Win9x code path.
- Removed the static instances of CSystemImageList and CShareEnumerator. These
changes along with the Win9x changes means that the code no longer supports
running on Win9x.
- Reworked the code so that calling SetRootFolder on a UNC server name now
works. The issue was that a path of the form "\\MACHINENAME" is not a true file
system path because only paths of the form "\\MACHINENAME\SHARE" allow file
enumeration. The code now explicitly checks the path and instead enumerates
the network resources below the UNC server name even when SetRootFolder has
been called. Thanks to Jan Moorman for reporting this issue.
v1.54 (8 January 2009)
- Updated copyright details.
- Fixed a bug in DisplayPath when it calls InsertFileItem to show the root
folder. The CFileTreeCtrlItemInfo pointer passed to InsertFileItem was not being
initialized with a valid m_NodeType value. Thanks to Colin Bouckaert for reporting
this bug.
- Fixed a bug in SetSelectedPath if you are trying to select a path when SetRootFolder
and SetShowRootedFolder have previously been called. Thanks to Colin Bouckaert
for reporting this bug.
v1.53 (13 December 2008)
- Optimized the memory usage by removing the m_bFileItem member variable from
CFileTreeCtrlItemInfo. Instead now whether an item is a File (as opposed to
a folder) is encoded into the m_NodeType value. In addition the m_nodeType value
has been made a BYTE value. This helps to save an additional 4 bytes per node.
Thanks to Michael Motje for prompting this update.
v1.52 (6 July 2008)
- Code now compiles cleanly using Code Analysis (/analyze)
- Updated code to compile correctly using _ATL_CSTRING_EXPLICIT_CONSTRUCTORS
define
- Shares shown underneath the Network node no longer show the share icon overlap.
This is consistent with how Windows Explorer shows these items.
- Fixed a bug where CFileTreeCtrl::OnChange was not being called due to the
fact that its message map entry was declared incorrectly. Thanks to "Roland"
for reporting this bug.
- Fixed a bug in CFileTreeCtrl::SetSelectedPath where the expansion state
of a folder was not being correctly set.
- Updated the sample app to allow the expansion state of the selected path
to be set.
- Fixed an issue where files and folders were not being displayed when the
desktop node was being reexpanded.
- Fixed an issue setting up m_sFQPath for some network node items in EnumNetwork
- During testing of the SetSelectedPath and because the control primarily
uses file paths to identify a node, refresh of items which do not have a corresponding
path will fail in OnRefresh. Examples of this include "My Network Places" and
"My Computer" amongst others. Until I develop a new version of the control based
on Shell PIDLs, this will be a deficiency of the current approach taken by CFileTreeCtrl
- Following analysis of the auto refresh behaviour of Windows Explorer, the
control now only monitors notifications for changes in the current directory
and not all drive letters or recursively from the current directory. This helps
to improve the robustness of control when change notifications are received.
v1.51 (2 May 2008)
- Updated copyright details.
- Updated the sample app to show how to implement a Vista style explorer tree
view if it is running on Vista. This functionality is implemented at the client
app level instead of the control code itself, so you can use this code from
the sample app if you want your client app's file tree control to look like
Vista's explorer.
- Removed VC 6 style appwizard comments from the code.
- General review and cleanup of all the code
- The code has now been updated to support VC 2005 or later only.
- Optimized CFileTreeCtrlItemInfo copy constructor code
- Removed CFileTreeCtrl::SetFlags method as it did not add any functionality
to the class.
- DRIVE_ATTRIBUTE_* defines are now enums in the CFileTreeCtrl class.
- Fixed bug in DisplayPath where if the desktop does not contain any files
or folders, you would not get a plus button for the desktop. Thanks to Steven
Tomer for reporting this bug.
- Prev and Next item stacks now store HTREEITEM's directly in their arrays.
- The control now supports showing the current users folder instead of (or
in addition to) the "My Documents" folder, similar to how the tree control behaves
in Windows Explorer on Vista. Note that the control does not show the "Public"
folder which Vista's Windows Explorer shows, because this is implemented as
a shell extension whereas this control is a ground up implementation of a file
tree control which does not use the Shell API's for enumerating the Shell Namespace.
- All the classes have been renamed from CTreeFileCtrl... to CFileTreeCtrl...
v1.50 (16 October 2007)
- Fixed a bug where if you attempt to create a new folder within a drive and
then immediately rename that folder to something else, the shell throws an error
about renaming a file and changing it's parent drive. Thanks to Michael Stephenson
for reporting this bug.
- Fixed a bug where if you delete a folder and it is the only folder under
it's parent folder, the parent retains it's "minus" icon, even though it no
longer has any children. Thanks to Michael Stephenson for reporting this bug.
- Fixed a bug where if you create a folder in a parent folder which did not
have any child items, the parent folder would not show the "minus" icon correctly.
Thanks to Michael Stephenson for reporting this bug.
v1.49 (13 June 2007)
- Reviewed class code for use of C++ casts instead of old style C casts.
- Desktop node item now includes a file system path in its CFileTreeCtrlItemInfo
pointer
- Made all BOOL members of CFileTreeCtrlItemInfo a "bool" to conserve memory
usage
- Replaced CFileTreeCtrlItemInfo member variables "m_bDesktopNode", "m_bNetworkNode"
& "m_bMyDocumentNode" with a single enum member variable
- Fixed a bug where rename would previously be allowed for nodes such as My
Documents, My Computers etc
- Fixed a bug where delete would previously be allowed for nodes such as My
Documents, My Computers etc
- Desktop node now also includes files and folders as found on the desktop.
Also the ordering of items on the desktop is consistent with how Explorer displays
the desktop.
- The shell is notified that a new directory has been created in CreateFolder
via the SHChangeNotify API
v1.48 (9 June 2007)
- Updated comments in documentation about usage of the Platform SDK.
- Internal WM_TREEUPDATE_CHANGE message is now defined as WM_APP instead of
WM_USER
- CreateFolder method now takes a second parameter which allows the new child
folder name to be set. If you leave this parameter as the default value of _T("")
then the new folder name will be created by calling the virtual CreateNewChildFolderName
function. This function has also been updated in this release to better encapsulate
how a new folder name is created.
- Return value from CreateFolder method is now a HTREEITEM instead of a BOOL
- Reworked the internal logic of CreateFolder method to avoid the need to
call the Refresh method. As a result the user experience is much improved due
to the elimination of the tree updates.
v1.47 (6 June 2007)
- Now supports in place creation of folders. Thanks to Phil Gibson for prompting
this update.
v1.46 (22 April 2007)
- Fixed a bug in CFileTreeCtrl::OnItemExpanding when the control is created
with the TVS_SINGLEEXPAND style. What was happening was that if for example
you selected C:\program files using SetSelectedPath, then you selected "C:\"
using the same function and then you selected "D:\", the control will end up
showing no plus button on the C node. Thanks to John Emmas for reporting this
quite difficult to find bug.
v1.45 (13 April 2007)
- Updated IsDropSource method to now allow drag / drop of folders. Thanks
to Kirk A. Baker for reporting this useful update.
- The class now supports multiple filename masks. To support this new functionality,
an updated / new set of functions have been provided, namely: AddMultipleFileNameMasks,
SetFileNameMask, AddFileNameMask, RemoveFileNameMask, GetFileNameMask & GetFileNameMasks.
Thanks to Fedor Gavrilov for this nice update.
v1.44 (30 March 2007)
- The icons used for computer nodes in Network neighborhood is now cached
in the CFileTreeCtrl constructor. This is a further improvement over the caching
of the local computer name approach which was used in the last version of the
code. If you do not want to use this approach, then you can define a FILETREECTRL_CACHE_COMPUTER_ICON
preprocessor value which will result in the computer icon being found when actual
network enumeration is performed. Thanks to Fotis Xomeritakis for this nice
optimization.
v1.43 (17 March 2007)
- Updated copyright details.
- Updated the sample apps to clean compile on VC 2005
- Added a preprocessor define "FILETREECTRL_NO_RESOURCES" which allows you
to use the CFileTreeCtrl code without the need to pull in any resources. Please
note that this will lead to reduced functionality of the control, for example
drag and drag will not be supported and all the menu functionality will also
be excluded. For exact details on what is out when you define this value, just
look for all occurences of FILETREECTRL_NO_RESOURCES in the FileTreeCtrl.cpp
module. Thanks to saukwan chou for reporting this issue.
- Optimized CFileTreeCtrl constructor code.
- Optimized CFileTreeCtrlThreadInfo constructor code.
- Optimized the code which gets the icon and "selected" icon for network servers
which are displayed by the class. What the code does is cache the local machine
name in the constructor and uses it to get the icon for a server when the code
is enumerating servers. This does mean that if MS ever brings in a mechanism
to allow customization of the icon on a server by server level, then CFileTreeCtrl
will ignore this. Thanks to Fotis Xomeritakis for providing this optimization
which really helps speed up the performance of CFileTreeCtrl when browsing domains
or workgroups with a large number of workstations and servers.
- Optimized CShareEnumerator constructor code.
- Sample Binaries included in download are now compiled with VC 2005 SP1
v1.41 (1 July 2006)
- Fixed a bug where expansion of UNC folders failed. Thanks to Jan Moorman
for reporting this bug.
v1.42 (1 July 2006)
- Updated the code to clean compile on VC 2005
- Code now uses new C++ style casts rather than old style C casts where necessary.
v1.40 (22 June 2006)
- Fixed a bug where expansion of the Desktop node fails on subsequent expansions.
Thanks to Jan Moorman for reporting this issue.
19 June 2006
- Updated the usage section to explain that the code now requires the Platform
SDK to be installed if you are compiling the code with VC 6.
- Added a missing manifest file to the zip download.
v1.39 (18 June 2006)
- Replaced all calls to ZeroMemory with memset
- Replaced all calls to CopyMemory with memcpy
- Optimized CFileTreeCtrlItemInfo constructor code
- Now includes code to optionally show "Desktop" as the root node. Thanks
to Hans Dietrich for this very nice addition
- Removed some now deleted files from the project.
- Fixed a minor typo in the Allow Properties menu item in the sample app.
- Now includes code to optionally show "My Documents". Thanks to Hans Dietrich
for this very nice addition.
- Fixed bug where m_bExtensionHidden setting was not being copied in CFileTreeCtrlItemInfo
constructor.
- Renamed SetDisplayNetwork to SetShowNetwork and GetDisplayNetwork to GetShowNetwork
for consistency with all the other functions of the same type.
v1.38 (25 January 2006)
- Updated the documentation to use the new style which the web site uses.
- Updated copyright details.
- Removed the GetChecked / SetChecked methods as CTreeCtrl as of VC++ 6 includes
equivalent functionality.
- The CanDisplayFolder method has been updated to use logic similar to the
CanDisplayFile virtual function. This new functionality is controlled by a new
m_dwFolderHideFlags variable which can be modified via the functions SetFolderHideFlags
& GetFolderHideFlags. Thanks to Bob O'Neil for this update.
- Reviewed all TRACE statements for correctness.
- Fixed an issue where you get an ASSERT in the code when you are using XP
manifest support and you are using the TVS_CHECKBOXES style in your CFileTreeCtrl.
The issue seems to be a bug in Commctrl v6 custom draw notifications as this
problem does not occur if you are not using XP themes. Thanks to Bob O'Neill
for this update.
v1.37 (21 June 2005)
- Fixed a bug where drag and drag mechanism had problems when trying to drag
an item into a folder immediately after the root item. Thanks to Larry Paul
for reporting this bug and provinding the fix.
- Fixed a number of compiler warnings when the code is compiled using Visual
Studio .NET 2003.
v1.36 (17 April 2005)
- Addition of TVIF_HANDLE to the mask fields in the functions GetIconIndex(HTREEITEM
hItem), GetSelIconIndex(HTREEITEM hItem) and SetHasPlusButton(HTREEITEM hItem,
BOOL bHavePlus). This avoids ASSERTs when the class is derived from the SECTreeCtrl
class in the Stingray Objective Toolkit. Thanks to Greg Marr for reporting this
problem.
- Addition of a "FILETREECTRL_EXT_CLASS" define to the class defintions. This
makes the code easier to use in an extension DLL.
- Code now uses the TVITEM structure name rather than TV_ITEM which is in
line with what is recommended by MS.
- Code now uses the TVINSERTSTRUCT structure name rather than TV_INSERTSTRUCT
which is in line with what is recommended by MS.
- Class now uses a preprocessor define of FILETREECTRL_BASE_CLASS to define
the class which CFileTreeCtrl is derived from. This allows the class to be used
with the Stingray Objective Toolkit without needing to modify the CFileTreeCtrl
source code.
- Optimized the code which deletes child nodes by now using TVE_COLLAPSERESET
flag.
- Removed the unused function NumberOfChildItems.
- Code now uses the NMTREEVIEW structure name rather than NM_TREEVIEW which
is in line with what is recommended by MS.
- Removed the now unused DeleteChildren method.
v1.35 (9 July 2004)
- Fixed a memory leak in the NETRESOURCE structure if client code returned
FALSE from CFileTreeCtrl::CanDisplayNetworkItem. Thanks to Michael Oerder reporting
this problem.
24 October 2003
- Updated the Usage section of the documentation to describe the need to copy
across the appropriate resources from the sample app.
5 October 2003
- Updated the Usage section of the documentation to describe an issue you
may encounter when you use the class in a CDialogBar derived class.
18 August 2003
- Removed CSortedArray from the download as it is available as a separate
download now.
v1.34 (5 July 2003)
- Updated the WM_DEVICECHANGE message handler in the sample app to use the
correct function signature for Visual Studio 6 and later. Thanks to Ed Eichman
for reporting this issue.
- Fixed a bug in the documentation of CFileTreeCtrl::SetDriveHideFlags. Thanks
to Ed Eichman for reporting this issue.
- Now documents the functions SetAutoRefresh and GetAutoRefresh. In addition
by default auto refresh is now turned off. Thanks to Ed Eichman for pointing
this out.
- Move sample workspace up to VC 6.
v1.33 (10 June 2003)
- Custom draw is now not used for items underneath Network Neighborhood. This
means that some items there will just display the standard network neighborhood
icon. To resolve this issue you would need to implement a completely new solution
using the shell API's. Thanks to John Noel for reporting a custom draw bug in
this area which has forced this change.
- m_sFQPath is now not filled in for virtual items such as My Computer and
Network Neighborhood. Thanks to Hans Dietrich for this suggestion.
v1.32 (31 May 2003)
- Fixed a bug where the filename mask was being ignored.
v1.31 (27 February 2003)
- Fixed more problems with refreshing and rooted paths. Thanks to Michael
J. Ryan for spotting this.
v1.30 (26 February 2003)
- Fixed a bug in CFileTreeCtrl::PathToItem which was causing refreshes to
fail when a rooted folder was being displayed. Thanks to Michael J. Ryan for
spotting this.
v1.30 of CSortedArray (24 January 2003)
- Made CSortedArray::Find method const. Thanks to Serhiy Pavlov for reporting
this.
v1.29 of CFileTreeCtrl (31 December 2002)
- Items are now sorted using the TVM_SORTCHILDRENCB Tree Control message.
This means that the class is no longer dependent on the CSortedArray class.
That class has been left in this download for convenience only. Thanks to "Vladi"
for this suggestion.
v1.29 of CSortedArray (11 December 2002)
- Optimized code by replacing all calls to CArray<>::ElementAt with CArray<>::GetData
v1.28 of CSortedArray (6 December 2002)
- Rewrote the Sort method following reports of further problems by Serhiy
Pavlov and Brian Rhodes.
v1.28 of CFileTreeCtrl (22 September 2002)
- Removed a number of unreferenced variables from the code, as highlighted
by Visual Studio.Net. Thanks to Bill Johnson for spotting this.
28 August 2002
- Updated sample app to automatically refresh upon removal or addition of
removal disk drives. Thanks to "kimo" for this update.
7 August 2002
- Fixed a bug in the sample app which ships with the class which was occurring
when you compiled the code in Visual Studio.Net. This was due to MS changing
the location oleimpl2.h header file. Thanks to Darren Schroeder for spotting
this problem.
v1.27 (5 June 2002)
- Implemented function "SetUsingDifferentColorForEncrypted" which was declared
but had no implementation.
- Fixed report of uninitialized member variable "m_nTimerID". Thanks to Emil
Isberg for spotting this.
v1.27 of CSortedArray (29 May 2002)
- Fixed a problem in CSortedArray::OrderedInsert. Thanks to John Young for
spotting and fixing this problem.
- Updated copyright and usage instructions
v1.26 (16 February 2002)
- Updated copyright message
- Fixed a drag/drop problem which caused the tree state to be inconsistent
after the file was dropped.
- Fixed a bug in the refresh code which was causing it to not reselect the
selected node after the refresh occurs. Thanks to John Noel for this fix.
- Fixed a problem where the custom draw icons for network nodes were not being
drawn in the correct positions when scrollbars were present in the control.
Again thanks to John Noel for this fix.
- Fixed a bug in SetSelectedPath which would not display the correct selection
if the node we want to select has been deleted due to the node becoming deleted
when it was previously collapsed. Thanks to Franz Fackelmann and John Noel for
spotting this problem.
v1.25 (24 December 2001)
- Fixed a copy and paste bug in GoForward. Thanks to Michael T. Luongo for
this fix.
- Now allows encrypted files to be displayed in a different colour
- Fixed memory leak which was occurring when control was being used in a dialog
- Fixed a problem with the calculation of indents when the style "TVS_LINESATROOT"
is used.
v1.24 (26 October 2001)
- Fixed some stability problems with the code. This was due to adding items
to the system image list. This is normally a very bad thing. Instead now the
code uses TreeView custom draw (just like the blue colour for compressed items)
to draw the icons for the Network Neighborhood items. Thanks to Darken Screamer
and Timo Haberkern for spotting this problem.
v1.23 (1 October 2001)
- Fixed another bug in CSortedArray::Sort!. Thanks to Jim Johnson for spotting
this.
v1.22 (11 August 2001)
- Fixed a bug in OnSelChanged which was causing a crash when you right click
on an empty area of the control. Thanks to Eli Fenton for spotting this one.
- The control now by default shows drives as children of "My Computer" just
like in Explorer.
- When you display a rooted directory in the control, you now have the option
of displaying the root folder in the control as the root item. Thanks to Eli
Fenton for suggesting this.
v1.21 (11 August 2001)
- Improved checking to see if action is allowed in Rename and Delete
- Fixed a bug in OnBeginLabelEdit
- Fixed a problem in OnEndLabelEdit which was causing renames to fail when
filename extensions were not being shown.
v1.2 (5 August 2001)
- You can now optionally display Network Neighborhood
- You can now turn on / off display of file extensions.
- You can now display shared items with a different icon
- Friendly names can now be displayed for drives.
v1.15 (5 May 2001)
- Updated copyright message.
- Fixed a resource leak where icon resources were not being released. Thanks
to Jay Kohler for spotting this problem.
v1.14 (2 October 2000)
- Fixed a stack overwrite problem in CSystemImageList::CSystemImageList.
- Removed an unreferenced variable in CFileTreeCtrl::OnSelChanged
- Removed an unreferenced variable in CFileTreeCtrl::OnItemExpanding
- Changed the SendMessage in CFileTreeCtrl::OnDblClk to prevent a crash which
was occurring when the open call sometimes caused a refresh call which changed
the tree items at times. When the double click message handler continued it
then caused item expand notifications for items already deleted and of course
crashes.
- Removed an unreferenced variable in CFileTreeCtrl::EndDragging6. Removed
an unreferenced variable in CFileTreeCtrl::KillNotificationThread
- Sample app now remembers the selected path and its expansion state across
invocations. Thanks to Mike Funduc for finding all these problems.
v1.13 (20 September 2000)
- Control now includes DECLARE_DYNCREATE thereby allowing it to be used in
code which requires this such as Stingray's SEC3DTabWnd. Thanks to Petter Nilsen
for pointing out this omission.
v1.12 (5 September 2000)
- Fixed a bug in CFileTreeCtrl::IsFile and CFileTreeCtrl::IsFolder
v1.11 (27 August 2000)
- Fixed another stack overflow problem in CSortedArray::Sort.
- Fixed a problem in CSortedArray::Sort where the comparison function was
returning negative values, 0 and positive values instead of -1, 0 & 1. Thanks
to Ted Crow for finding both of these problems.
- Updated the documentation for SetCompareFunction on what values are expected
to be returned from it.
v1.10 (24 July 2000)
- Fixed a bug where the expansion state of the selected item was not being
preserved across refreshes.
- Now includes full support for Next / Prev support similar to Windows Explorer
with the Desktop Update.
- Updated sample app to have some useful toolbars.
- Changing any tree settings which can affect its appearance now force a refresh
of its contents.
- ItemToPath method has been made const.
- Addition of PathToItem method
- Auto refresh of items is now provided for by means of change notification
threads. This is configurable via the SetAutoRefresh method.
- The root folder of the tree control can now be changed from the sample app
- Fixed a bug in SetRootFolder when passed an empty folder
- Fixed a bug where the system image list was not being initialized correctly
if the user did not have a "C:\\" drive. This could occur on NT/Windows2000
- Fixed a bug in IsFile and IsFolder which was causing invalid files or folders
to appear valid.
- Deleted items are now removed upon expansion. Also if the item being expanded
was deleted and it was the only child, then its parent has the "-" expansion
button removed
- Removable drive nodes are collapsed back to their root nodes if their media
is changed in the intervening time when a node expansion occurs.
- Wait cursor is now displayed while a refresh is taking place.
- A "OnSelectionChanged" virtual function has now been provided
- Sample app's icon has been made the same as Explorers.
- Sample app now displays the path name of the currently selected item in
the tree control.
- Fixed a bug in IsCompressed
- items are now deleted when selected if they do not exist.
v1.09 (18 July 2000)
- Now uses ON_NOTIFY_REFLECT_EX instead of ON_NOTIFY_REFLECT for handling
reflected messages. This allows derived classes to handle these messages also.
Thanks to Christian Dahl for this.
- Sample app now allows drag drop behaviour to be toggled
- Fixed a problem whereby two items were left selected after you did a drag
/drop operation. Thanks to Jonathon Ralston for this.
- Removed function declaration for unused function "InsertDriveItem".
- Removed an unreferenced variable in InsertFileItem.
- Tidied up the UpOneLevel functions and made it public.
- Removed all the message handlers in the sample code which reflect straight
down to the tree control. Instead the OnCmdMsg first routes the message to this
class.
- Renamed all menu items which CFileTreeCtrl uses to include the prefix TREEFILECTRL
- Renamed all the methods to more generic names
- PreTranslateMessage now uses PostMessage instead of calling functions directly.
This allows up to function correctly for derived classes in addition to correctly
disabling items through the OnUpdate mechanism
- Removed an unreferenced variable in OnRclick
- Removed the unreferenced variable m_hSelItem
- Optimized a number of expressions by putting the boolean comparisons first
- m_bAllowRename parameter is now observed for in place editing of an item
- Now supports hiding of Drive types via the SetDriveHideFlags function. See
the menu options on the Tools menu in the sample program for its usage.
- Filename masks can now be specified via the SetFileNameMask method. See
the menu options on the Tools menu in the sample program for its usage.
- File types can now be specified via the GetFileHideFlags function. See the
menu options on the Tools menu in the sample program for its usage.
- Fixed a small issue in one of my calls to ::GetKeyState
- Fixed a bug where programs was crashing if an icon index for it could not
be found.
- Made many of the methods of CFileTreeCtrl virtual, thus allowable better
use in end user derived classes.
- Fixed problem where SetSelectedPath(_T("C:\\"), FALSE) was resulting in
the drive being expanded even through FALSE was being sent in to specify that
the item should not be expanded.
- A virtual "CanDisplayFile" has been added to allow you to decide at runtime
whether or not a certain file is to be displayed.
- A virtual "CanDisplayFolder" has been added to allow you to decide at runtime
whether or not a certain folder is to be displayed
- Now optionally displays compressed files in a different Colour, similar
to explorer. The Colour is customizable through the class API.
- Code has been made smarter so that it does not have to spin up the floppy
disk to determine if there are files on it. It now initially displays a "+"
and only when you try to expand it will it do the actual scan.
v1.08 (13 May 2000)
- Fixed a problem where items on the context menu were being invoked for the
wrong item when you right mouse click over an item that is not the selected
item. Behaviour now is that the item is selected prior to showing the context
menu. Now, this is same behaviour as Explorer.
v1.07 (2 April 2000)
- Fixed a small bug in CFileTreeCtrl::SetRootFolder
- Fixed the problem with initialisation errors in the code. Client code must
not explicitly call PopulateTree when the window is created. When used in a
dialog resource this is not necessary as it is called for you in the DDX functions.
- Sample app now also include the control in the about box as an example.
v1.06 (29 February 2000)
- Fixed a problem in CSortedArray::Sort when there are no items in the array
v1.05 (22 February 2000)
- Fixed a problem in CSortedArray::Find when there are no items in the array
v1.04 (21 February 2000)
- Fixed a number of problems in CSortedArray::Find
v1.03 (31 January 2000)
- Fixed a problem when you right mouse click over a non - selected item. The
control now implements the same behaviour as Explorer for this.
- Removed check for keyboard invocation of the context menu in OnContextMenu
- Now displays the context menu over the selected item when invoked via the
keyboard. Again this is the same behaviour as Explorer has.
- Optimized the code in PreTranslateMessage.
- Fixed a bug in CFileTreeCtrl::OnEndlabeledit
- Some of the menus in the sample app have been fixed.
- Menu items have been added to the sample app to allow the SetAllow... functions
to be tried out.
v1.02 (25 January 2000)
- Minor update to the code in CFileTreeCtrl::OnDblclk to only allow selected
items to be opened.
v1.01 (12 January 2000)
- Added some asserts to HasGotSubEntries.
- Fixed a problem with calling OnDblclk when no tree item is selected.
- Removed an unused variable from SetSelectedPath.
- Fixed a stack overflow in CSortedArray::Sort.
- Now supports check boxes with each item in the tree control.
v1.0 (27 December 1999)
API Reference
The following functions are provided:
CFileTreeCtrl::CFileTreeCtrl
CFileTreeCtrl::SetRootFolder
CFileTreeCtrl::GetRootFolder
CFileTreeCtrl::ItemToPath
CFileTreeCtrl::GetSelectedPath
CFileTreeCtrl::SetSelectedPath
CFileTreeCtrl::SetShowFiles
CFileTreeCtrl::GetShowFiles
CFileTreeCtrl::SetAllowDragDrop
CFileTreeCtrl::GetAllowDragDrop
CFileTreeCtrl::SetAllowRename
CFileTreeCtrl::GetAllowRename
CFileTreeCtrl::SetAllowOpen
CFileTreeCtrl::GetAllowOpen
CFileTreeCtrl::SetAllowProperties
CFileTreeCtrl::GetAllowProperties
CFileTreeCtrl::SetAllowDelete
CFileTreeCtrl::GetAllowDelete
CFileTreeCtrl::SetAllowCreateFolder
CFileTreeCtrl::GetAllowCreateFolder
CFileTreeCtrl::IsFile
CFileTreeCtrl::IsFolder
CFileTreeCtrl::IsDrive
CFileTreeCtrl::IsCompressed
CFileTreeCtrl::Rename
CFileTreeCtrl::ShowProperties
CFileTreeCtrl::Delete
CFileTreeCtrl::Open
CFileTreeCtrl::PopulateTree
CFileTreeCtrl::SetDriveHideFlags
CFileTreeCtrl::GetDriveHideFlags
CFileTreeCtrl::SetFileHideFlags
CFileTreeCtrl::GetFileHideFlags
CFileTreeCtrl::SetFolderHideFlags
CFileTreeCtrl::GetFolderHideFlags
CFileTreeCtrl::AddMultipleFileNameMasks
CFileTreeCtrl::GetFileNameMasks
CFileTreeCtrl::GetCompressedColor
CFileTreeCtrl::SetCompressedColor
CFileTreeCtrl::GetUsingDifferentColorForCompressed
CFileTreeCtrl::SetUsingDifferentColorForCompressed
CFileTreeCtrl::SetShowNetwork
CFileTreeCtrl::GetShowNetwork
CFileTreeCtrl::SetUsingDifferentIconForSharedFolders
CFileTreeCtrl::GetUsingDifferentIconForSharedFolders
CFileTreeCtrl::GetShowFileExtensions
CFileTreeCtrl::SetShowFileExtensions
CFileTreeCtrl::SetNetworkItemTypes
CFileTreeCtrl::GetNetworkItemTypes
CFileTreeCtrl::SetShowDriveLabels
CFileTreeCtrl::GetShowDriveLabels
CFileTreeCtrl::SetShowMyComputer
CFileTreeCtrl::GetShowMyComputer
CFileTreeCtrl::SetShowDesktop
CFileTreeCtrl::GetShowDesktop
CFileTreeCtrl::SetShowMyDocuments
CFileTreeCtrl::GetShowMyDocuments
CFileTreeCtrl::SetShowCurrentUserFolder
CFileTreeCtrl::GetShowCurrentUserFolder
CFileTreeCtrl::SetShowRootedFolder
CFileTreeCtrl::GetShowRootedFolder
CFileTreeCtrl::GoBack
CFileTreeCtrl::CanGoBack
CFileTreeCtrl::GoForward
CFileTreeCtrl::CanGoForward
CFileTreeCtrl::GetMaxHistory
CFileTreeCtrl::SetMaxHistory
CFileTreeCtrl::GetBackSize
CFileTreeCtrl::GetBackItemText
CFileTreeCtrl::GetForwardSize
CFileTreeCtrl::GetForwardItemText
CFileTreeCtrl::SetAutoRefresh
CFileTreeCtrl::GetAutoRefresh
DDX_FileTreeValue
CFileTreeCtrl::CFileTreeCtrl
CFileTreeCtrl();
Remarks
Constructs a CFileTreeCtrl object.
CFileTreeCtrl::SetRootFolder
void SetRootFolder(const CString& sPath);
Parameters
sPath The folder to use as the parent for all items in the tree control.
Remarks
This allows you to set the parent folder to be something other than the default
which displays all the drive letters at the root. For example this would allow you
to produce a UI to allow you to specify a "Program Group" as would be required
by an install program.
CFileTreeCtrl::GetRootFolder
CString GetRootFolder() const;
Return Value
The current folder used as the parent for all items in the tree control.
Remarks
This is the corollary function to the SetRootFolder function.
CFileTreeCtrl::ItemToPath
virtual CString ItemToPath(HTREEITEM hItem);
Return Value
The folder / file path as represented by the tree item hItem.
Parameters
hItem The tree item to get the path for.
Remarks
This function allows an tree item's file name or folder name to be retrieved
given it's HTREEITEM. Internally this function is used in the GetSelectedPath function.
CFileTreeCtrl::GetSelectedPath
CString GetSelectedPath();
Return Value
The current folder / file path as selected in the tree control.
Remarks
This function returns the file name or folder name currently selected in the
tree control.
CFileTreeCtrl::SetSelectedPath
void SetSelectedPath(const CString& sPath, bool bExpanded =
false);
Parameters
sPath The folder or file name path to select in the tree control.
bExpanded true if the new item should be shown expanded otherwise
false.
Remarks
This allows you to set the currently selected item in the tree control.
CFileTreeCtrl::SetShowFiles
void SetShowFiles(bool bFiles);
Parameters
bFiles true if the tree control should display files in addition to
folders.
Remarks
This allows you to decide whether the tree control should display files.
CFileTreeCtrl::GetShowFiles
bool GetShowFiles() const;
Return Value
true if the tree control is displaying files otherwise false.
Remarks
This is the corollary function to the SetShowFiles function.
CFileTreeCtrl::SetAllowDragDrop
void SetAllowDragDrop(bool bAllowDragDrop);
Parameters
bAllowDragDrop true if the tree control should allow drag/drop of items
otherwise false.
Remarks
This allows you to decide whether the tree control should allow drag/drop of
items.
CFileTreeCtrl::GetAllowDragDrop
bool GetAllowDragDrop() const;
Return Value
true if the tree control is allowing drag/drop otherwise false.
Remarks
This is the corollary function to the SetAllowDragDrop function.
CFileTreeCtrl::SetAllowRename
void SetAllowRename(bool bAllowRename);
Parameters
bAllowRename true if the tree control should allow items to be renamed
otherwise false.
Remarks
This allows you to decide whether the tree control should allow items to be renamed
(via the F2 keyboard accelerator and in-place editing of items).
CFileTreeCtrl::GetAllowRename
bool GetAllowRename() const;
Return Value
true if the tree control is allowing items to be renamed otherwise
false.
Remarks
This is the corollary function to the SetAllowRename function.
CFileTreeCtrl::SetAllowOpen
void SetAllowOpen(bool bAllowOpen);
Parameters
bAllowOpen true if the tree control should allow items to be "opened"
via the shell.
Remarks
This allows you to decide whether the tree control should allow items to be "opened"
via the shell (via the Enter keyboard accelerator and double clicking of items).
CFileTreeCtrl::GetAllowOpen
bool GetAllowOpen() const;
Return Value
true if the tree control is allowing items to be opened via the shell
otherwise false.
Remarks
This is the corollary function to the SetAllowOpen function.
CFileTreeCtrl::SetAllowProperties
void SetAllowProperties(bool bAllowProperties);
Parameters
bAllowProperties true if the tree control should allow an item's property
dialog to be displayed.
Remarks
This allows you to decide whether the tree control should allow property dialogs
to be displayable (via the Alt-Enter keyboard accelerator).
CFileTreeCtrl::GetAllowProperties
bool GetAllowProperties() const;
Return Value
true if the tree control is allowing an item's property dialog to be
displayable otherwise false.
Remarks
This is the corollary function to the SetAllowProperties function.
CFileTreeCtrl::SetAllowDelete
void SetAllowDelete(bool bAllowDelete);
Parameters
bAllowDelete true if the tree control should allow items to be deleted.
Remarks
This allows you to decide whether the tree control should allow items to be deleted
(via the Delete keyboard accelerator).
CFileTreeCtrl::GetAllowDelete
bool GetAllowDelete() const;
Return Value
true if the tree control is allowing items to be deleted otherwise
false.
Remarks
This is the corollary function to the SetAllowDelete function.
CFileTreeCtrl::SetAllowCreateFolder
void SetAllowDelete(bool bAllowCreateFolder);
Parameters
bAllowCreateFolder true if the tree control should allow folder creation.
Remarks
This allows you to decide whether the tree control should allow new folders to
be created.
CFileTreeCtrl::GetAllowCreateFolder
bool GetAllowCreateFolder() const;
Return Value
true if the tree control is allowing folder creation otherwise
false.
Remarks
This is the corollary function to the SetAllowCreateFolder function.
CFileTreeCtrl::IsFile
virtual bool IsFile(HTREEITEM hItem);
virtual
bool IsFile(const CString& sPath);
Return Value
true if the tree control item or path is a file otherwise false.
Parameters
hItem The tree item to be determined if it is a file.
sPath The path of the object to be determined if it is a file.
Remarks
Use these functions to determine if an item is a file.
CFileTreeCtrl::IsFolder
virtual bool IsFolder(HTREEITEM hItem);
virtual bool IsFolder(const CString& sPath);
Return Value
true if the tree control item or path is a folder / directory otherwise
false.
Parameters
hItemThe tree item to be determined if it is a folder / directory.
sPath The path of the object to be determined if it is a folder / directory.
Remarks
Use these functions to determine if an item is a folder / directory.
CFileTreeCtrl::IsDrive
virtual bool IsDrive(HTREEITEM hItem);
virtual
bool IsDrive(const CString& sPath);
Return Value
true if the tree control item or path is a drive letter otherwise
false.
Parameters
hItem The tree item to be determined if it is a drive letter.
sPath The path of the object to be determined if it is a drive letter.
Remarks
Use these functions to determine if an item is a drive letter e.g. "A:\".
CFileTreeCtrl::IsCompressed
virtual bool IsCompressed(const CString& sPath);
Return Value
true if the tree control item is a compressed file otherwise false.
Parameters
sPath The path of the object to be determined if it is a compressed
file.
Remarks
Use this function to determine if an item is a compressed file. This is used
internally by the control when drawing compressed files in a different colour
CFileTreeCtrl::Rename
virtual bool Rename(HTREEITEM hItem);
Return Value
true if in-place editing of the specified item was started successfully
otherwise false.
Parameters
hItem The tree item to begin in-place editing of.
Remarks
Use this function to start in-place editing i.e. renaming of the specified item.
To edit a specific path use the function "SetSelectedPath".
CFileTreeCtrl::ShowProperties
virtual bool ShowProperties(HTREEITEM hItem);
Return Value
true if the shells property dialog of the specified item was shown
successfully otherwise false.
Parameters
hItem The tree item to show the properties dialog of.
Remarks
Use this function to show the standard Windows properties dialog of an item.
To show the properties of a specific path use the function "SetSelectedPath".
CFileTreeCtrl::Delete
virtual bool Delete(HTREEITEM hItem);
Return Value
true if the item was successfully deleted otherwise false.
Parameters
hItem The tree item to delete.
Remarks
Use this function to delete the specified item. To delete a specific path use
the function "SetSelectedPath". Internally the function looks at the keyboard
state to implement real deletion or moving of the item to the recycle bin. It will
also use the standard confirmation dialogs provided by the shell when you delete
something.
CFileTreeCtrl::Open
virtual bool Open(HTREEITEM hItem);
Return Value
true if the item was successfully "opened" by the shell otherwise
false.
Parameters
hItem The tree item to "open".
Remarks
Use this function to "open" the specified item. In the case of an executable,
the program will be run, while in the case of a document file, the default verb
as setup in the shell will be used. To execute a specific path use the function
"SetSelectedPath".
CFileTreeCtrl::PopulateTree
virtual void PopulateTree();
Remarks
You need to call this function to populate the tree control with contents if
you manually create the view. If you are using the control in a dialog resource
and are using the DDX functions provided for it, then this function will be called
for you automatically.
CFileTreeCtrl::SetDriveHideFlags
void SetDriveHideFlags(DWORD dwDriveHideFlags);
Parameters
dwDriveHideFlags A bit mask of the drives to hide from the tree control
Remarks
This allows you to specify the types of drives which are not to be displayed
in the tree control.
The flags that can be used are as follows:
DRIVE_ATTRIBUTE_REMOVABLE
|
The disk can be removed from the drive.
|
DRIVE_ATTRIBUTE_FIXED
|
The disk cannot be removed from the drive.
|
DRIVE_ATTRIBUTE_REMOTE
|
The drive is a remote (network) drive.
|
DRIVE_ATTRIBUTE_CDROM
|
The drive is a CD-ROM drive.
|
DRIVE_ATTRIBUTE_RAMDISK
|
The drive is a RAM disk.
|
The flags can be or'ed together when calling the function.
CFileTreeCtrl::GetDriveHideFlags
DWORD GetDriveHideFlags() const;
Return Value
The bit mask of drive types to be excluded from the tree control
Remarks
This is the corollary function to the SetDriveHideFlags function.
CFileTreeCtrl::SetFileHideFlags
void SetFileHideFlags(DWORD dwFileHideFlags);
Parameters
dwFileHideFlags A bit mask of the files to hide from the tree control
Remarks
This allows you to specify the types of files which are not to be displayed in
the tree control.
The flags that can be used are as follows:
FILE_ATTRIBUTE_ARCHIVE |
The file is an archive file. Applications use this attribute
to mark files for backup or removal. |
FILE_ATTRIBUTE_COMPRESSED |
The file is compressed. For a file, this means that all
of the data in the file is compressed. |
FILE_ATTRIBUTE_ENCRYPTED |
The file is encrypted. For a file, this means that all data
streams in the file are encrypted. |
FILE_ATTRIBUTE_HIDDEN |
The file is hidden. It is not included in an ordinary directory
listing. |
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED |
The file will not be indexed by the content indexing service. |
FILE_ATTRIBUTE_OFFLINE |
The data of the file is not immediately available. This
attribute indicates that the file data has been physically moved to offline
storage. This attribute is used by Remote Storage, the hierarchical storage
management software in Windows 2000. Applications should not arbitrarily
change this attribute. |
FILE_ATTRIBUTE_READONLY |
The file is read-only. Applications can read the file but
cannot write to it or delete it. In the case of a directory, applications
cannot delete it. |
FILE_ATTRIBUTE_REPARSE_POINT |
The file has an associated reparse point. |
FILE_ATTRIBUTE_SPARSE_FILE |
The file is a sparse file. |
FILE_ATTRIBUTE_SYSTEM |
The file is part of, or is used exclusively by, the operating
system. |
FILE_ATTRIBUTE_TEMPORARY |
The file is being used for temporary storage. File systems
attempt to keep all of the data in memory for quicker access rather than
flushing the data back to mass storage. A temporary file should be deleted
by the application as soon as it is no longer needed. |
The flags can be or'ed together when calling the function.
CFileTreeCtrl::GetFileHideFlags
DWORD GetFileHideFlags() const;
Return Value
The bit mask of file types to be excluded from the tree control
Remarks
This is the corollary function to the SetFileHideFlags function.
CFileTreeCtrl::SetFolderHideFlags
void SetFolderHideFlags(DWORD dwFileHideFlags);
Parameters
dwFolderHideFlags A bit mask of the files / folders to hide from the
tree control
Remarks
This allows you to specify the types of folders which are not to be displayed
in the tree control.
The flags that can be used are as follows:
FILE_ATTRIBUTE_ARCHIVE |
The directory is an archive file or directory. Applications
use this attribute to mark files for backup or removal. |
FILE_ATTRIBUTE_COMPRESSED |
The directory is compressed. For a directory, this means
that compression is the default for newly created files and subdirectories. |
FILE_ATTRIBUTE_ENCRYPTED |
The directory is encrypted. For a directory, this means
that encryption is the default for newly created files and subdirectories. |
FILE_ATTRIBUTE_HIDDEN |
The directory is hidden. It is not included in an ordinary
directory listing. |
FILE_ATTRIBUTE_NOT_CONTENT_INDEXED |
The file will not be indexed by the content indexing service. |
FILE_ATTRIBUTE_OFFLINE |
The data of the file is not immediately available. This
attribute indicates that the file data has been physically moved to offline
storage. This attribute is used by Remote Storage, the hierarchical storage
management software in Windows 2000. Applications should not arbitrarily
change this attribute. |
FILE_ATTRIBUTE_READONLY |
The directory is read-only. Applications can read the file
but cannot write to it or delete it. In the case of a directory, applications
cannot delete it. |
FILE_ATTRIBUTE_REPARSE_POINT |
The file has an associated reparse point. |
FILE_ATTRIBUTE_SPARSE_FILE |
The file is a sparse file. |
FILE_ATTRIBUTE_SYSTEM |
The file or directory is part of, or is used exclusively
by, the operating system. |
FILE_ATTRIBUTE_TEMPORARY |
The file is being used for temporary storage. File systems
attempt to keep all of the data in memory for quicker access rather than
flushing the data back to mass storage. A temporary file should be deleted
by the application as soon as it is no longer needed. |
The flags can be or'ed together when calling the function.
CFileTreeCtrl::GetFolderHideFlags
DWORD GetFileHideFlags() const;
Return Value
The bit mask of folder types to be excluded from the tree control
Remarks
This is the corollary function to the SetFolderHideFlags function.
CFileTreeCtrl::AddMultipleFileNameMasks
void AddMultipleFileNameMasks(const CString& sFileNameMasks);
Parameters
sFileNameMasks A string search mask to use for specifing certain files
to be included in the tree control e.g. "*.cpp,*.c;*.h,*.inl". Note that a comma
or semicolon are both valid delimiters
Remarks
This allows you to specify the types of files to be included for example based
on their extension, e.g "*.exe". By default the mask is set to "*.*".
CFileTreeCtrl::GetFileNameMasks
CString GetFileNameMasks() const;
Return Value
The string search mask in use
Remarks
This is the corollary function to the AddMultipleFileNameMasks function.
CFileTreeCtrl::SetCompressedColor
void SetCompressedColor(COLORREF rgbCompressed);
Parameters
rgbCompressed The colour to use to display compressed files
Remarks
This allows you to specify the colour compressed files are drawn in. By default
the colour is RGB(0, 0, 255) i.e blue which is the same as "Explorer".
CFileTreeCtrl::GetCompressedColor
CString GetCompressedColor() const;
Return Value
The colour in use for displaying compressed files
Remarks
This is the corollary function to the SetCompressedColor function.
CFileTreeCtrl::SetUsingDifferentColorForCompressed
void SetUsingDifferentColorForCompressed(bool bShowCompressedUsingDifferentColor);
Parameters
bShowCompressedUsingDifferentColor true if compressed files should
be drawn differently to normal files, otherwise false to leave compressed files
drawn using the normal colour.
Remarks
This allows you to turn on or off whether compressed files show be drawn differently.
Please note that version 4.70 or later of Comctrl32.dll (Internet Explorer 3 and
later) is required for this to work. The code will work on machines with earlier
versions, but compressed files will be displayed as standard files.
CFileTreeCtrl::GetUsingDifferentColorForCompressed
bool GetUsingDifferentColorForCompressed() const;
Return Value
true if compressed files should be drawn differently to normal files,
otherwise false to leave compressed files drawn using the normal colour.
Remarks
This is the corollary function to the SetUsingDifferentColorForCompressed function.
CFileTreeCtrl::SetShowNetwork
void SetShowNetwork(bool bShowNetwork);
Parameters
bShowNetwork true if the network should be shown, otherwise false to
only show local files and mapped drives (i.e. drive letters).
Remarks
This allows you to enumerate the network in addition to showing local files.
CFileTreeCtrl::GetShowNetwork
bool GetShowNetwork() const;
Return Value
true if network is being shown, otherwise false.
Remarks
This is the corollary function to the SetShowNetwork function.
CFileTreeCtrl::SetUsingDifferentIconForSharedFolders
void SetUsingDifferentIconForSharedFolders(bool bShowSharedUsingDifferentIcon);
Parameters
bShowSharedUsingDifferentIcon true if folders which are shared should
be shown as such, otherwise false to leave shared folders drawn using the normal
icon.
Remarks
This allows you to show folders which are shared, just like the way Explorer
shows them.
CFileTreeCtrl::GetUsingDifferentIconForSharedFolders
bool GetUsingDifferentIconForSharedFolders() const;
Return Value
true if folders which are shared are shown using a different icon,
otherwise false.
Remarks
This is the corollary function to the SetUsingDifferentIconForSharedFolders function.
CFileTreeCtrl::SetShowFileExtensions
void SetShowHideExtensions(HideFileExtensions FileExtensions);
Parameters
FileExtensions An enum controlling how file extensions should be shown.
Remarks
This allows you to decide how extensions will be shown.
The HideFileExtensions enum can have the following values:
HideExtension |
File extensions are not shown. |
DoNoHideExtension |
File extensions are shown. |
UseTheShellSetting |
File extensions are shown/not shown consistent with the
setting for the Shell/Explorer. |
CFileTreeCtrl::GetShowFileExtensions
HideFileExtensions GetShowFileExtensions() const;
Return Value
enum which contains how file extensions are currently being shown.
Remarks
This is the corollary function to the SetShowFileExtensions.
CFileTreeCtrl::SetNetworkItemTypes
void SetNetworkItemTypes(DWORD dwTypes);
Parameters
dwTypes A DWORD controlling what network items are to be shown.
Remarks
This allows you to decide what items on the network should be shown.
The dwType can have the following values:
RESOURCETYPE_ANY
|
All resources (this value cannot be combined with RESOURCETYPE_DISK or
RESOURCETYPE_PRINT).
|
RESOURCETYPE_DISK
|
All disk resources.
|
RESOURCETYPE_PRINT
|
All print resources.
|
CFileTreeCtrl::GetNetworkItemTypes
DWORD GetNetworkItemTypes() const;
Return Value
DWORD which contains what network items are currently being shown.
Remarks
This is the corollary function to the SetNetworkItemTypes.
CFileTreeCtrl::SetShowDriveLabels
void SetShowDriveLabels(bool bShowDriveLabels);
Parameters
bShowDriveLabels true to allow friendly names to be displayed for drive
letters otherwise false.
Remarks
When bShowDriveLabels is set to true, a friendly version of a drive is shown
e.g. instead of "D:" being shown, you might get "Compact Disc (I:)".
CFileTreeCtrl::GetShowDriveLabels
bool GetShowDriveLabels() const;
Return Value
true if friendly names are being displayed for drives otherwise
false.
Remarks
This is the corollary function to the SetShowDriveLetters.
CFileTreeCtrl::SetShowMyComputer
void SetShowMyComputer(bool bShowMyComputer);
Parameters
bShowMyComputer true if drive letters should be rooted by a "My Computer"
node, false to leave drive letters unrooted.
CFileTreeCtrl::GetShowMyComputer
bool GetShowMyComputer() const;
Return Value
true if "My Computer" is to be used as the root for drive letters otherwise
false.
Remarks
This is the corollary function to the SetShowMyComputer.
CFileTreeCtrl::SetShowDesktop
void SetShowDesktop(bool bShowDesktop);
Parameters
bShowDesktop true if the "Desktop" node should be shown,
false to not
show it.
CFileTreeCtrl::GetShowDesktop
bool GetShowDesktop() const;
Return Value
true if "Desktop" is to be shown otherwise false.
Remarks
This is the corollary function to the SetShowDesktop.
CFileTreeCtrl::SetShowMyDocuments
void SetShowMyDocuments(bool bShowMyDocuments);
Parameters
bShowMyDocuments true if the "My Documents" node should be shown,
false
to not show it.
CFileTreeCtrl::GetShowMyDocuments
bool GetShowMyDocuments() const;
Return Value
true if "My Documents" is to be shown otherwise false.
Remarks
This is the corollary function to the SetShowMyDocuments.
CFileTreeCtrl::SetShowCurrentUserFolder
void SetShowCurrentUserFolder(bool bShowCurrentUserFolder);
Parameters
bShowMyDocuments true if the Current User's Folder node should be shown,
false to not show it. Vista's explorer shows the complete folder for the current
user instead of "My Documents". The CFileTreeCtrl by default implements this same
behaviour.
CFileTreeCtrl::GetShowCurrentUserFolder
bool GetShowCurrentUserFolder() const;
Return Value
true if the Current User's Folder is to be shown otherwise
false.
Remarks
This is the corollary function to the SetShowCurrentUserFolder.
CFileTreeCtrl::SetShowRootedFolder
void SetShowRootedFolder(bool bShowRootedFolder);
Parameters
bShowRootedFolder true to allow the root directory to be shown as the
parent node when you use SetRootFolder otherwise false to not show the root folder.
CFileTreeCtrl::GetShowRootedFolder
bool GetShowRootedFolder() const;
Return Value
true if the root folder is show as the parent node otherwise false.
Remarks
This is the corollary function to the SetShowRootedFolder.
CFileTreeCtrl::GoBack
virtual bool GoBack();
Return Value
true if the control successfully went back to the item just previously
visited.
Remarks
This allows you to turn navigate just like Explorer provides for using the "Back"
button.
CFileTreeCtrl::CanGoBack
bool CanGoBack() const;
Return Value
true if there are items which can be gone back to
Remarks
This is used by the sample app to enable / disable the "Back" toolbar button.
CFileTreeCtrl::GoForward
virtual bool GoForward();
Return Value
true if the control successfully went to the next item.
Remarks
This allows you to turn navigate just like Explorer provides for using the "Forward"
button.
CFileTreeCtrl::CanGoForward
bool CanGoForward() const;
Return Value
true if there are items which can be gone "forward" to
Remarks
This is used by the sample app to enable / disable the "Forward" toolbar button.
CFileTreeCtrl::GetMaxHistory
virtual int GetMaxHistory();
Return Value
the maximum items which can be put onto the Back / Forward stacks.
Remarks
By default the stack sizes are 20.
CFileTreeCtrl::SetMaxHistory
virtual void SetMaxHistory(int nMaxHistory)
const;
Parameters
nMaxHistory The maximum size the Back / Forward stacks can grow to.
Remarks
You can use this function to set the size of Back / Forward stacks.
CFileTreeCtrl::GetBackSize
int GetBackSize();
Return Value
the current number of items on the "Back" stack.
CFileTreeCtrl::GetBackItemText
CString GetBackItemText(int nBack);
Return Value
the text associated with the specific item on the "Back" stack.
Parameters
nBack The zero based index of the item to get the text of.
Remarks
Allows you to retrieve the text associated with a certain "Back" item. This could
be used by client apps to implement a drop down menu of previous items just like
Internet Explorer provides.
CFileTreeCtrl::GetForwardSize
int GetForwardSize();
Return Value
the current number of items on the "Forward" stack.
CFileTreeCtrl::GetForwardItemText
CString GetForwardtemText(int nBack);
Return Value
the text associated with the specific item on the "Forward" stack.
Parameters
nBack The zero based index of the item to get the text of.
Remarks
Allows you to retrieve the text associated with a certain "Forward" item. This
could be used by client apps to implement a drop down menu of previous items just
like Internet Explorer provides.
CFileTreeCtrl::SetAutoRefresh
void SetAutoRefresh(bool bAutoRefresh);
Parameters
bAutoRefresh true if the tree control should auto refresh and false
to disable.
Remarks
Turning on auto refresh allows the control to montor changes that take place
on the file system and automatically update the control with this new information.
By default this feature is off.
CFileTreeCtrl::GetAutoRefresh
bool GetAutoRefresh() const;
Return Value
true if the tree control is performing auto refresh otherwise
false.
Remarks
This is the corollary function to the SetAutoRefresh function.
DDX_FileTreeValue
void DDX_FileTreeValue(CDataExchange* pDX,
CFileTreeCtrl& ctrlFileTree, CString& sItem);
Parameters
pDX is the usual CDataExchange object which will be passed into your
DoDataExchange function.
ctrlFileTree is the tree control to get or set the folder / file for.
sItem is the actual folder / file to get or set into the control depending
on the direction of data exchange occurring.
Remarks
Allows the selected folder / file to be quickly set / retrieved in a CFileTreeCtrl
instance using the normal MFC DDX mechanism.
Contacting the Author
PJ Naughter
Email: pjna@naughter.com
Web: http://www.naughter.com
4 May 2020