
Unit LsFileExplorer27.pas

==============================================================================
Archive    :- FileExpl.zip

Components :- TLsDirTree20 w/TLsDirTree20PopUp, 
              TLsDirTreeCombo27 and
              TLsFilelistView27 w/TLsFilelistView27PopUp

Version    :- 2.70  (For Delphi versions 3, 4 & 5)

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

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

------------------------------------------------------------------------------
DISCLAIMER :- These components are currently distributed as Freeware,
              without 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.

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

1. Brief Description
====================

  1.1 TLsDirTree20 w/TLsDirTree20Popup
  ------------------------------------
  TLsDirTree20 is a simple but fully functional Directory TreeView, that
  displays the structure of the File System. It supports creating, renaming
  and deleting of directories, it can also calculate the size of a selected
  portion of the directory-tree, through the use of its context menu.

  1.2 TLsDirTreeCombo27
  ---------------------
  TLsDirTreeCombo27 is a specialized ComboBox with a dropdown Directory
  TreeView, that is similar to TLsDirTree20, displaying a hierarchical tree
  of drives and directories in the File System.

  1.3 TLsFilelistView27 w/TLsFilelistViewPopUp26
  ----------------------------------------------

  TLsFilelistView27 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.

  TLsFilelistViewPopUp26 is LsFilelistView27's build-in Context Menu, containing
  commands that perform operations on files.



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

 2.1 TLsFilelistView27
 ---------------------

  2.1.1 Published 
  ---------------
   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 TLsFilelistView27.
                      Changing the value of this property will update the
                      TLsFilelistView27 to display items in the new directory.

   DirTree          - Provides a simple way to connect TLsFilelistView27 to
                      TLsDirTree20 component.

   DirTreeCombo     - Provides a simple way to connect TLsFilelistView27 to
                      TLsDirTreeCombo27 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.

   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
  ------------

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

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

 2.2 TLsDirTreeCombo27
 ---------------------

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

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

   FileList         - Provides a way to connect TLsDirTreeCombo27 to
                      TLsFilelistView27.

   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 LsDirTreeCombo27.

 2.3 TLsDirTree20
 ----------------

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

   FileList         - Provides a way to connect TLsDirTree20 to TLsFilelistView27.

   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 TLsFilelistView27
 ---------------------

   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.

   SetColumnWidth   - Set the width of Columns 0 to 4.  The default setting is:

                         SetColumnWidth(160, 90, 90, 100, 40);

                      If the Width of a column is set to zero, that column will
                      be invisible.


 3.2 TLsDirTreeCombo27
 ---------------------

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

   ResetTreeView    - Reload the TLsDirTreeView.

 3.3 TLsDirTree20
 ----------------

   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.


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

   Unzip FileExpl.zip to any directory, then copy LsFileExplorer27.pas,
   LsFileExplorer27.dcr and LsFileExplorer27.res to a directory that is in the
   Lib search path.


 4 For Delphi versions 3x , 4x  & 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 LsFileExplorer27.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 TLsDirTree20 (or TLsDirTreeCombo27) and TLsFilelistView27
components in an application, they must be mutually connected through the use
of the TLsDirTree20's (or TLsDirTreeCombo27's) 'FileList' property and the
TLsFileListView25's 'DirTree' property (or 'DirTreeCombo' property if
TLsDirTreeCombo27 is used). Once they are interconnected, changes in one
component will be automatically reflected in the other component.

For example, the LsDirTree20 and LsFilelistView27 components in your application
are named as LsDirTree201 and LsFilelistView271 respectively. You can use Object
Inspector to set LsDirTree201's 'FileList' property to LsFilelistView271; likewise,
set LsFilelistView271's 'DirTree' property to LsDirTree201.


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

     5.2.1 TLsDirTree20 and TLsDirTreeCombo27
     ==========================================================================     
     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 TLsFilelistView27
     ==========================================================================
     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 TLsFilelistView27
     ==========================================================================

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

     5.3.1 LsFileListView27Popup
     ================================================================
     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 LsDirTree20PopUp
     ================================================================
     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
     ================================================================

     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 TLsFilelistView27 is set to True, GetNextItem
    function 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.70
-------------
    (B) LsDirTree20:

      - Add Function GetTreeSize.

      - Add Bipmaps to its PopupMenu.

    (A) 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 TLsDirTreeCombo27.
    - 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 TLsFilelistView27.
    - 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 TLsDirTreeCombo27, and revised ShortCut keys
      in TLsFilelistView27 in order to conform with standard shortcuts
      used by Windows Explorer.
    - Added procedure FindFile to TLsFilelistView27.
    - In LsFilelistView27, 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 TLsDirTreeCombo27, has been SentToBack.
    - Incorporated patches to TLsFilelistView27 to avoid possible AV errors.

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

 Version 2.50
 ------------
    - TLsDirComboBox has been replaced by TLsDirTreeCombo27, in order to
      provide a hierarchical treeview of the file system.
    - Added SetColumnWidth() procedure to TLsFilelistView27.
    - Added ShowFolders property to TLsFilelistView27.
    - 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 TLsFilelistView27'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 TLsFilelistView27 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 TLsDirTreeCombo27'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
-----------------------------------------------------------------------------
