TCustomShellListView.PopulateWithRoot procedure
Fills the list view with file system information for the directory in Root.
Declaration
procedure PopulateWithRootDescription
PopulateWithRoot is a procedure used to fill the
Items
property with file system entries for the directory specified in
Root.
No actions are performed in the method at design-time, or when Root contains an empty string (''). In addition, the actions may be delayed if the Handle for control has not been allocated. An internal flag is set to indicate the condition, and PopulateWithRoot will be called again when the Handle is created in CreateHandle.
PopulateWithRoot calls the GetFilesInDirectory helper routine in the implementation section to get a list of file system items for the path which match the Mask and ObjectTypes specified for the control. Each of the files in the list are passed to DoAddItem / OnAddItem to determine if they can be added to the Items property.
The add method in Items is called to create the list items which represent each of the files or directories. If a list item is a TShellListItem class type, its FileInfo property is updated with the file information from the TFileItem created in the GetFilesInDirectory helper.
The Caption in the list item is set to the file or directory name. SubItems are added to the TListItem instance to store file system information displayed in the Size and Type columns on the List view. For a file, the file size and file extension are added to the SubItems. For a directory, the first subitem is an empty string (since directories do not have a size) and the second is set to the sShellCtrlsFolder constant.
When UseBuiltInIcons is set to True, the GetBuiltInImageIndex method
is called to get the ImageIndex for the built-in icon on a list item. This
action is performed using the path to the current file name when LargeImages
and/or SmallImages have not been assigned. The value in ViewStyle determines
the image size requested. When ViewStyle is vsIcon, LargeImages is
checked (when assigned). Otherwise, SmallImages is checked (when assigned).
If an image list exists in either LargeImages or SmallImages, the existing
ImageIndex in the list item is used.
The OnFileAdded event handler is signalled (when assigned) for each new entry added to Items.
The Sort method is called prior to exit to order the Items in the control using the option specified in the FileSortType property.
Updated in LCL version 3.0 to use TShellListItem as the item class for list items.
See also
An experiment, built from development snapshots. Not the official Free Pascal or Lazarus documentation.
