
Unit LsFileExplorer28.pas  v2.80
==============================================================================

Archive       :- FileExpl.zip

Components    :- TLsDirTree21, TLsDirTreeCombo28 and
                 TLsFilelistView28

Version       :- 2.80  For Delphi versions 3, 4 and 5

Author        :- Leo D. Shih <ldshih@ecn.ab.ca>

Copyright     :- (C)1998/2000 Leo D. Shih, All rights reserved

Last Modified :- July 2000

------------------------------------------------------------------------------
DISCLAIMER
==========
  These components are currently distributed as Freeware,  and may be
  freely distributed or used in Delphi applications, commercial or
  otherwise, provided that (a) the source code is unmodified and (b)
  this notice remains intact.

  There is absolutely no warranty of any kind, either expressed or implied.
  In no event shall the author be liable for any problems or damages that
  may result from the use of these components.

  Suggestions for improvement or bug-fixing will be welcome.
------------------------------------------------------------------------------
ACKNOWLEDGMENTS
===============
  I'm most grateful to those people in the Delphi community who have
  reported bugs, suggested fixings or recommanded improvements. In
  particular, I would like to thank Ales Trtnik, Brad Huggins,
  Claude Hunter, Detlef Scheil, Harrie Roaymans, Marcelo Rodrigues,
  Helmut Knaack, Peter Caliban, Steve Pinneo, and Tom Lisjac for their
  professional suggestions.

------------------------------------------------------------------------------
Brief Description
=================

  1.1 TLsDirTree21
  ----------------
  TLsDirTree21 is a simple but fully functional Directory TreeView with a
  popup FileListDlg (i.e. a simplified File ListView), that
  (a) displays drives/directories in the DirectoryTree and files of the
      selected directory in a popup FileListDlg.  Thus, directories can be
      selected from the DirectoryTree, and files can be selected or opened
      in the FileListDlg;
  (b) supports creating, renaming and deleting operation on directories;
  (c) calculates the size of a selected portion of the directory-tree.

  1.1 TLsDirTreeCombo28
  ---------------------
  TLsDirTreeCombo28 is a specialized ComboBox with a dropdown Directory
  TreeView, that displays a hierarchical tree of drives and directories of
  the File System.

  1.3 TLsFilelistView28 w/TLsFilelistViewPopUp28
  ----------------------------------------------

  TLsFilelistView28 is a File ListView component. In addition to its normal
  functions, It also performs various file management tasks, such as cut, copy,
  paste, rename, delete, open, view and send_to operations on files.  It also
  provides statistics on Disk-FreeSpace, Selected-Numbers and Selected-Size as
  those available in the Windows Explorer.

  TLsFilelistViewPopUp28 is LsFilelistView28's build-in Context Menu, that
  contains commands for performing various file operations.



2. Added properties:
===================

 2.1 TLsFilelistView28
 ---------------------

  2.1.1 Published Properties
  --------------------------

   ColWidth_Name    - Set the width of FileName column, Default 165.

   ColWidth_Size    - Set the width of FileSize column, Default 75.

   ColWidth_Type    - Set the width of FileType column, Default 95.

   ColWidth_Mod     - Set the width of FileLastWriteTime column, Default 115.

   ColWidth_Attr    - Set the width of FileAttributes column, Default 40.

                     (NB:- If the Width of a column is set to zero, that column
                           will be invisible).

   DateFormat       - Provides eight preset ShortDate Formats and a Customize
                      option:

                         Option         Format              Remarks
                         ==========     ================    =================
                         df_Customize   User configuable
                         df_ddMMyy_DE   dd.MM.yy            German
                         df_ddMMyy_GB   dd/MM/yy            British / French
                         df_ddMMyy_IT   dd-MM-yy            Italian
                         df_ddMMyyyy    dd/MM/yyyy          British
                         df_MMddyy      MM/dd/yy            American
                         df_MMddyyyy    MM/dd/yyyy            - " -
                         df_yyMMdd      yy-MM-dd            Ansi / Japan
                         df_yyyyMMdd    yyyy-MM-dd            - " -

                      When 'Customize' option is selected, the Regional setting
                      in Windows Control Panel is used, thus the DateFormat can
                      be configured by users at runtime.

   TimeFormatStr    - is Time Style format string, for example HH:mm:ss.
                      If this property is empty, the Regional setting in Windows
                      Control Panel will be used, thus it's user configurable.

   DblClickToOpen   - Option to disable the build-in DblClick procedure, thus
                      users can code their own OnDblClick Handler. (It was named
                      as DblClickEnabled in previous version)

   Directory        - Currently selected directory that contains files and/or
                      sub-directories to be displayed in the TLsFilelistView28.
                      Changing the value of this property will update the
                      TLsFilelistView28 to display items in the new directory.

   DirTree          - Provides a simple way to connect TLsFilelistView28 to
                      TLsDirTree21 component.

   DirTreeCombo     - Provides a simple way to connect TLsFilelistView28 to
                      TLsDirTreeCombo28 component.

   DriveFreeSpace   - Free space on the current drive, in kB.

   FileType         - Determines which file types are displayed based on the
                      attributes of files. FileTypes included are ftReadOnly,
                      ftHidden, ftSystem, ftArchive, ftNormal.

   HideFileExt      - If it's set to True, file extensions will not be displayed.

   Mask             - Limits which files are displayed. Default mask is '*.*'.
                      (To specify multiple masks, separate the file mask spec.
                      with semicolons).

   PopupMenuEnabled - Option to disable the build-in Context-Menu, thus allowing
                      users to use the PopupMenu Property for their own popupmenu.

   SelectedItem     - The FullName of the selected Item (path + ItemName).

   SelectedNumber   - Number of selected items in the current directory.

   SelectedSize     - Total bytes of selected items in the current directory.

   ShowFolders      - Specifies whether or not folders are shown in the
                      FilelistView26 together with files.


  2.1.2 Public
  ------------

   DirectorySize    - Total bytes of files in the current directory, excluding
                      sub-directories, if any.

 2.2 TLsDirTreeCombo28
 ---------------------

  2.2.1 Published
  ---------------

   SelectedPath     - The Directory Path of the currently selected treenode in
                      the TLsDirTreeCombo28.

   FileList         - Provides a way to connect TLsDirTreeCombo28 to
                      TLsFilelistView28.

   ExpandRoot       - Specifies whether the RootNode is expanded.

   TreeHeight       - Set the Height of the drop-down treeview, default is 195.

   Glyph            - An option to load an alternative bitmap to replace the
                      default Glyph in the button of LsDirTreeCombo28.

 2.3 TLsDirTree21
 ----------------

   SelectedPath     - The Directory Path of the currently selected treenode in
                      the TLsDirTree21.

   SelectedFile     - The FileName( FilePath + FileName) of the selected item
                      in the popup FileListDlg.

   FileList         - Provides a way to connect TLsDirTree21 to TLsFilelistView28.

   PopupMenuEnabled - Option to disable the buildin Context-Menu, thus allow
                      users to use the PopupMenu Property for their own popupmenu.


3. Added Procedures/Functions (Public):
======================================

 3.1 TLsFilelistView28
 ---------------------

   OneLevelUp       - A step back in the directory hierarchy (ie. move to its
                      parent node).

   CutCopy()        - |
                      |
   Paste            - |  Perform copy, move, delete or rename operation on files.
                      |-
   DeleteItems      - |  Using CutCopy(0) for Copy and
                      |        CutCopy(2) for Cut opration.
   RenameFile       - |

   FindFile         - To activate Windows FindDialog for locating specified file.

   FileAttr         - To view or edit the selected item's attributes.

   OpenItem         - Open executable files or other type of files which have
                      been associated with their respective applications in the
                      Windows Registry.

   ViewFile         - Provides programmers with a quick viewer of *.c, *.cpp,
                      *.dpk, *.dpr, *.h, *.inf, *.ini, *.pas, *.prg, *.txt,
                      *.doc, *.rtf, *.wri, and *.bmp files

   NewFolder        - Create a new folder.


 3.2 TLsDirTreeCombo28
 ---------------------

   OpenPath()       - To select a treenode in accordance with the specified
                      directory path.

   ResetTreeView    - Reload the TLsDirTreeView.

 3.3 TLsDirTree21
 ----------------

   OpenPath()       - To select a treenode in accordance with the specified
                      directory path.

   ReLoad           - Reload the TLsDirTree.

   AddNewNode()     - Add a new directory to the file system.

   DeleteNode()     - Delete an existing directory from the file system.

   GetTreeSize()    - Calculate the TreeSize of the selected Directory and all
                      its sub-directories.

   ShowFolderContents - Activate the popup FileListDlg, to display files in the
                      selected directory.


4. Installation
===============

   Unzip FileExpl.zip to any directory, then copy LsFileExplorer28.pas,
   LsFileExplorer28.dcr and LsFileExplorer28.res to a directory that is
   in the Delphi's Library search path.


 4 For Delphi versions 3x , 4x and 5x
 -------------------------------------

   All three components can be added to an existing Package, eg. Samples or
   Delphi User's Components Package, by following steps:
   - Choose Component|Install Component; ensure that 'Into existing package'
     tab is selected and the 'Package file name' is correct.
   - From Install Component Dialog, click Browse.
   - In the Unit FileName Dialog, navigate to your chosen directory and
     select LsFileExplorer28.pas, then click Open.
   - In the Install Component Dialog, click OK to compile and install the
     package.
   - Finally, right-click the Package Editor Diallog and save the package.


5. Notes on Usage
=================

5.1 Interconnecting components
------------------------------

If you use both TLsDirTree21 (or TLsDirTreeCombo28) and TLsFilelistView28
components in an application, they must be mutually connected through the use
of the TLsDirTree21's (or TLsDirTreeCombo28's) 'FileList' property and the
TLsFileListView28's 'DirTree' property (or 'DirTreeCombo' property if
TLsDirTreeCombo28 is used). Once they are interconnected, changes in one
component will be automatically reflected in the other component.

For example, the LsDirTree21 and LsFilelistView28 components in your application
are named as LsDirTree211 and LsFilelistView281 respectively. You can use Object
Inspector to set LsDirTree211's 'FileList' property to LsFilelistView281;
likewise, set LsFilelistView281's 'DirTree' property to LsDirTree211.


5.2 ShortCut Keys
-----------------

     5.2.1 TLsDirTree21 and TLsDirTreeCombo28
     ==========================================================================
     ShortCut Key(s)   Action
     ----------------  --------------------------------------------------------
     RightArrow        Expand the current selected node, if it is not expanded

     LeftArrow         Collapse the current selected node, if it is expanded

     F4                Display LsDirTreeView

     Esc               Close LsDirTreeView

     DownArrow         If current selected node is expanded, move to nextChild;
                       otherwise move to nextvisible node

     UpArrow           If current node is expanded, move to preChild; otherwise
                       move to prevVisible node

     Enter             Set the SelectedPath
     ==========================================================================

     5.2.2 TLsFilelistView28
     ==========================================================================
     ShortCut Key(s)   Action
     ----------------  --------------------------------------------------------
     Ctrl+C            Copy

     Ctrl+X            Cut

     Ctrl+V            Paste

     Ctrl+O            Open Files

     Ctrl+F            Quick view

     Ctrl+N            Create New Folder

     UpArrow           Move up

     DownArrow         Move down

     Delete            Send selected items to Recycle Bin

     Enter             Open (Files or Folders)

     BackSpace         Go to the parent folder

     F2                Rename file

     F3                Find Files

     F5                Refresh TLsFilelistView28
     ==========================================================================

5.3 Popup Context Menu
----------------------

     5.3.1 LsFilelistView28Popup
     =========================================================================
     Menu Name            Commands / Remarks
     ---------------      ----------------------------------------------------
     Open                 OpenItem
     View                 ViewFile
     ---------------
     Send To >            To open Send_To SubMenu, which contains:
                           - Any Folder ... ,
                           - Clipboard as Contents,
                           - Clipboard as FileName,
                           - Removable Disk(s), and
                           - LinkFiles in \Windows\SendTo directory.
     ---------------
     Cut                  CutCopy(2)
     Copy                 CutCopy(0)
     Paste                Paste
     ---------------
     Rename File          RenameFile
     Delete               DeleteItems
     ---------------
     Attributes           FileAttr
     ---------------
     New Folder           NewFolder
     =========================================================================


     5.3.2 LsDirTree21PopUp
     =========================================================================
     Menu Name            Commands / Remarks
     ---------------      ----------------------------------------------------
     Add Folder           AddNewNode()       / Creates a new directory
     Rename Folder                           / Rename an existing directory
     Delete Folder        DeleteNode()       / Delete an existing directory
     ---------------
     TreeSize             GetTreeSize()      / Calculate the TreeSize from
                                               selected Directory
     Folder Contents      ShowFolderContents / Popup FileListDlg for displaying
                                               files in the selected directory

     =========================================================================

     NB:- These file- and folder-management operations can easily be
          linked to the application's main menu by adding few lines
          of code.

5.4 If MultiSelect Property of TLsFilelistView28 is set to True, GetNextItem
    function or a for-loop can be used to find all selected items.


6. Limitation
=============

    Since these components are designed mainly for file management, Special
    DesktopFolders are not retrieved from the shell's name space and
    displayed in both components.

7 History
=========

 Version 2,80
 ------------
    (A) LsDirTree21

      - Add TLsFileListDlg Class for creating a popup FileList-Dialog,
        i.e. a simplified FileListView, that will display files in the
        selected directory of LsDirTree21.

      - Add ShowFolderContents procedure to activate LsFileListDlg.

      - Fixed bug in AddNewNode( )

    (B) LsDirTreeCombo28

      - Fixed bug when compiled under Japanese edition of Delphi.

    (C) LsFilelistView28:

      - procedure SetColumnWidth() replaced by properties:
           ColWidth_Name,
           ColWidth_Size,
           ColWidth_Type,
           ColWidth_Mod, and
           ColWidth_Attr.

      - When ViewStyle = vsReport, the File Size will be displayed in KBs and
        the Folder Size will be blank.

      - The "Parent" folder will stay at top, regardless sorting directions.

      - Fixed "Invalid image" error, when the icon-size is changed from default
        size of 32x32 (in Windows' Display Property | Appearance | Icon ).


 Version 2.70
-------------
    (A) LsDirTree20:

      - Add Function GetTreeSize.

      - Add Bipmaps to its PopupMenu.

    (B) LsFilelistView27:

      - Added Property HideFileExt.

      - Added Property TimeFormatStr

      - Revised Procedure SetDateFormat to increse preset DateFormats
        and to provide customize option.

      - Added Bitmaps to the ColumnHeaders to indicate the sorted column
        and its direction of sorting.

      - Added Bitmaps to the its PopupMenu.

      - Added a 'Parent' folder at the top of filelist. Double-click on it,
        will go up one level (similar to Procedure OneLevelUp).

      - Enhancements to various functions and procedures.


 Version 2.60
 ------------
    - Added a Directory-TreeView component 'TLsDirTree20'.

    - Revised the KeyDown Event handler in TLsDirTreeCombo26.

    - Included icons in Send-To context menu (for D4 and D5).

    - Fixed bug that keep the drop-down LsDirTreeView on Top, when using
      Alt-Tab key to switch to other running application.

 Version 2.53
 ------------
    - Added PopupMenu and DblClickEnabled Properties to TLsFilelistView25.

    - Fixed 'Integer overflow or Floating point error' generated by Functions
      GetDiskSizze() or GetFreeDiskSize(). if the disk size or the logical
      partition size is larger than 4GB.

    - Fixed bug in Procedure TLsDirtreeCombo().

    - Compiler Directives modified in order to be compatible with Delphi 5.

 Version 2.52
 ------------
    - Added ShortCut keys to TLsDirTreeCombo25, and revised ShortCut keys
      in TLsFilelistView25 in order to conform with standard shortcuts
      used by Windows Explorer.

    - Added procedure FindFile to TLsFilelistView25.

    - In LsFilelistView25, Public Property FileName has been renamed to
      SelectedItem to reflect its function and FileAttrhas been declared
      as public.

    - Fixed bug that keep the drop-down LsDirTreeView on Top, even the
      application that owns TLsDirTreeCombo25, has been SentToBack.

    - Incorporated patches to TLsFilelistView25 to avoid possible AV errors.

 Version 2.51
 ------------
    - Fixed the undesired behavior of TLsDirTreeCombo25's dropdown
      treeview, if it's located on any component other than a TForm.

 Version 2.50
 ------------
    - TLsDirComboBox has been replaced by TLsDirTreeCombo25, in order to
      provide a hierarchical treeview of the file system.

    - Added SetColumnWidth() procedure to TLsFilelistView25.

    - Added ShowFolders property to TLsFilelistView25.

    - Added 'Anchors', 'BiDiMode' and 'Constraints' properties for Delphi
      version 4.xx.

    - Added Attributes to Context Menu

    - Send_To SubMenu has been revised.

    - Fixed bug in TLsFilelistView25's AddFiles() function.

 Version 2.00
 ------------
    - Use Windows API functions to perform copy, move, rename,
      delete, and other operations on files.

    - Added DriveFreeSpace, SelectedNumber and SelectedSize
      properties.

    - Also added an Popup Context Menu to TLsFilelistView20 for
      file operations.

 Version 1.20
 ------------
    - Added compiler directives to migrate both components to
      Delphi version 4.

 Version 1.10
 ------------
    - Fixed bugs in TLsFilelistView's Mask property to allow
      folders and filtered files to be displayed simultaneously.

    - Fixed bugs in TLsDirTreeCombo10's Click procedure.

 Version 1.00
 ------------
    - First development.

 Note :-   Latest patches in the source code are flagged by
           '//'+ minor version number.
           eg. //51 indicates changes made in version 2.51
-----------------------------------------------------------------------------
