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
History
Usage
Copyright
API Reference
Contacting the Author

 

 

 

Features

 

 

 

Usage

 

 

 

Copyright

 

 

 

History

v1.62 (4 May 2020)

v1.61 (15 March 2020)

v1.60 (21 December 2019)

v1.59 (29 September 2019)

v1.58 (21 July 2019)

v1.57 (6 June 2016)

v1.56 (7 April 2013)

v1.55 (6 April 2013)

v1.54 (8 January 2009)

v1.53 (13 December 2008)

v1.52 (6 July 2008)

v1.51 (2 May 2008)

v1.50 (16 October 2007)

v1.49 (13 June 2007)

v1.48 (9 June 2007)

v1.47 (6 June 2007)

v1.46 (22 April 2007)

v1.45 (13 April 2007)

v1.44 (30 March 2007)

v1.43 (17 March 2007)

v1.41 (1 July 2006)

v1.42 (1 July 2006)

v1.40 (22 June 2006)

19 June 2006

v1.39 (18 June 2006)

v1.38 (25 January 2006)

v1.37 (21 June 2005)

v1.36 (17 April 2005)

v1.35 (9 July 2004)

24 October 2003

5 October 2003

18 August 2003

v1.34 (5 July 2003)

v1.33 (10 June 2003)

v1.32 (31 May 2003)

v1.31 (27 February 2003)

v1.30 (26 February 2003)

v1.30 of CSortedArray (24 January 2003)

v1.29 of CFileTreeCtrl (31 December 2002)

v1.29 of CSortedArray (11 December 2002)

v1.28 of CSortedArray (6 December 2002)

v1.28 of CFileTreeCtrl (22 September 2002)

28 August 2002

7 August 2002

v1.27 (5 June 2002)

v1.27 of CSortedArray (29 May 2002)

v1.26 (16 February 2002)

v1.25 (24 December 2001)

v1.24 (26 October 2001)

v1.23 (1 October 2001)

v1.22 (11 August 2001)

v1.21 (11 August 2001)

v1.2 (5 August 2001)

v1.15 (5 May 2001)

v1.14 (2 October 2000)

v1.13 (20 September 2000)

v1.12 (5 September 2000)

v1.11 (27 August 2000)

v1.10 (24 July 2000)

v1.09 (18 July 2000)

v1.08 (13 May 2000)

v1.07 (2 April 2000)

v1.06 (29 February 2000)

v1.05 (22 February 2000)

v1.04 (21 February 2000)

v1.03 (31 January 2000)

v1.02 (25 January 2000)

v1.01 (12 January 2000)

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