diff --git a/docs/xml/lcl/shellctrls.xml b/docs/xml/lcl/shellctrls.xml
index 5975f2e11b..4577ff2401 100644
--- a/docs/xml/lcl/shellctrls.xml
+++ b/docs/xml/lcl/shellctrls.xml
@@ -101,6 +101,8 @@ to implement the TCustomShellTreeView.FileSortType property.
+TFileItem is a utility class used to represent a file or directory.
+It contains BasePath with the path to the directory where the item is located
+on the local file system, and FileInfo with the TSearchRec values for the item.
+
+TFileItem is the type used to represent the items passed as arguments to a
+TFileItemCompareEvent handler routine. TFileItem instances are created and
+used in the implementation of file listing and sort routines as well.
+
+isFolder is a Boolean member which indicates if the item
+represents a folder or directory on the local file system. Its value is
+assigned in the Create constructor, and is set to True if the TSearchRec
+instance in the DirInfo argument includes faDirectory in its Attr member.
+
+Create stores values in the DirInfo and ABasePath arguments to the
+FileInfo and BasePath properties in the class instance. isFolder is updated to
+indicate whether the file item is a directory on the local file system.
+
+BasePath is assigned in the Create constructor using the value
+passed in the ABasePath argument.
+
+FileInfo is assigned in the Create constructor using the value
+passed in the DirInfo argument.
+
+TFileItemCompareEvent is the type used to implement the
+OnSortCompare event handler in TCustomShellTreeView. TFileItemCompareEvent
+compares the file items specified in the Item1 and Item2 arguments to
+determine which value occurs first in the sort order.
+
+The return value is an Integer with the relative sort order for the
+compared values:
+
+An application can implement and assign a routine using the signature to the
+OnSortCompare event handler in TCustomShellTreeView. Set its FileSortType
+property to fstCustom to enable the handler routine.
+
+The following is an item compare function, as implemented by forum member
+d7_2_laz, used to order items with leading Underscore characters:
+
+Sort File Items by Date
+
+Sort File Items by Size
+
+
+
+function TForm1.SortCompareUnderscore(Item1, Item2: TFileItem): integer;
+begin
+ // Make sure that folders are moved to the top
+ Result := ord(Item2.isFolder) - ord(Item1.isFolder);
+ if Result = 0 then
+ if (pos('_', Item1.FileInfo.Name) = 1) or
+ (pos('_', Item2.FileInfo.Name) = 1) then
+ Result := AnsiCompareText(Item1.FileInfo.Name, Item2.FileInfo.Name)
+ else
+ Result := CompareText(Item1.FileInfo.Name, Item2.FileInfo.Name);
+end;
+
+
+function TForm1.SortCompareByDate(Item1, Item2: TFileItem): integer;
+begin
+ // Folders first ...
+ Result := ord(Item2.isFolder) - ord(Item1.isFolder);
+ if Result = 0 then
+ begin
+ // then file date ...
+ Result := CompareValue(Item1.FileInfo.TimeStamp, Item2.FileInfo.TimeStamp);
+ if Result = 0 then
+ // then file name
+ Result := CompareText(Item1.FileInfo.Name, Item2.FileInfo.Name);
+ end;
+end;
+
+
+function TForm1.SortCompareBySize(Item1, Item2: TFileItem): integer;
+begin
+ // Folders first
+ Result := ord(Item2.isFolder) - ord(Item1.isFolder);
+ if Result = 0 then
+ begin
+ // then file size ...
+ Result := Item1.FileInfo.Size - Item2.FileInfo.Size;
+ if Result = 0 then
+ // then file name
+ Result := CompareText(Item1.FileInfo.Name, Item2.FileInfo.Name);
+ end;
+end;
+
+
+OnSortCompare is a TFileItemCompareEvent property with +the event handler signalled to implement a custom file sort for the tree view +control. OnSortCompare is used to order the directories or files displayed in +the tree view control when its FileSortType property is set to fstCustom. +
++Changing the routine assigned to the property causes the Items in the control +to be reloaded and ordered using the new file sort compare routine. +
++An application can implement and assign a routine using the signature perform +custom file comparison routines using various attributes. The following is an +item compare function, as implemented by forum member d7_2_laz, used to order +items with leading Underscore characters: +
+
+function TForm1.SortCompareUnderscore(Item1, Item2: TFileItem): integer;
+begin
+ // Make sure that folders are moved to the top
+ Result := ord(Item2.isFolder) - ord(Item1.isFolder);
+ if Result = 0 then
+ if (pos('_', Item1.FileInfo.Name) = 1) or
+ (pos('_', Item2.FileInfo.Name) = 1) then
+ Result := AnsiCompareText(Item1.FileInfo.Name, Item2.FileInfo.Name)
+ else
+ Result := CompareText(Item1.FileInfo.Name, Item2.FileInfo.Name);
+end;
+
++Sort File Items by Date +
+
+function TForm1.SortCompareByDate(Item1, Item2: TFileItem): integer;
+begin
+ // Folders first ...
+ Result := ord(Item2.isFolder) - ord(Item1.isFolder);
+ if Result = 0 then
+ begin
+ // then file date ...
+ Result := CompareValue(Item1.FileInfo.TimeStamp, Item2.FileInfo.TimeStamp);
+ if Result = 0 then
+ // then file name
+ Result := CompareText(Item1.FileInfo.Name, Item2.FileInfo.Name);
+ end;
+end;
+
++Sort File Items by Size +
+
+function TForm1.SortCompareBySize(Item1, Item2: TFileItem): integer;
+begin
+ // Folders first
+ Result := ord(Item2.isFolder) - ord(Item1.isFolder);
+ if Result = 0 then
+ begin
+ // then file size ...
+ Result := Item1.FileInfo.Size - Item2.FileInfo.Size;
+ if Result = 0 then
+ // then file name
+ Result := CompareText(Item1.FileInfo.Name, Item2.FileInfo.Name);
+ end;
+end;
+
+