
Unit LsFileExplorer26.pas

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

Components :- TLsDirTree10 w/TLsDirTreePopUp10, 
              TLsDirTreeCombo26 and
              TLsFilelistView26 w/TLsFilelistViewPopUp26

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

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

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

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

  1.1 TLsDirTree10 w/TLsDirTreePopup10
  ------------------------------------

  TLsDirTree10 is a descendant of TreeView component, that displays the directory
  structure of the File System. It also supports creating, renaming and deleting
  operations on directories through the use of its context menu.

  1.2 TLsDirTreeCombo26
  ---------------------

  TLsDirTreeCombo26 is a ComboBox with a dropdown TreeView, that displays a
  hierarchical tree of directories in the File System.

  1.3 TLsFilelistView26 w/TLsFilelistViewPopUp26
  ----------------------------------------------

  TLsFilelistView26 is a File ListView component. In addition to its normal
  functions, It also encapsulates SHFileOperation and other Windows API
  functions to perform 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 LsFilelistView26's build-in Context Menu, containing
  commands that perform operations on files.



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

 2.1 TLsFilelistView26
 ---------------------

  2.1.1 Published 
  ---------------
   DateFormat       - Set the Files' datetime to one of the following
                      ShortDateFormat:
                           [dfMDY] = mm/dd/yyyy
                           [dfDMY] = dd/mm/yyyy
                           [dfYMD] = yyyy/mm/dd

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

   DirTree          - Provides a simple way to connect TLsFilelistView26 to
                      TLsDirTree10 component.

   DirTreeCombo     - Provides a simple way to connect TLsFilelistView26 to
                      TLsDirTreeCombo26 component.

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

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

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

   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.
                                                                                                                                             
   PopupMenuEnabled - Option to disable the build-in Context-Menu, thus allowing
                      users to use the PopupMenu Property for their own popupmenu.                                                                                                 

   DblClickEnabled  - Option to disable the build-in DblClick procedure, thus
                      users can code their own OnDblClick Handler.

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

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

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

   FileList         - Provides a way to connect TLsDirTreeCombo26 to
                      TLsFilelistView26.

   ExpandRoot       - Specifies whether the RootNode is expanded.

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

   Glyph            - In D2, to load an bitmap for TLsDirTreeCombo26's button;
                      while in D3, D4 or D5, to load an alternative bitmap file
                      to replace the default Glyph in the button.                                                                                    

 2.3 TLsDirTree10
 ---------------- 

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

   FileList         - Provides a way to connect TLsDirTree10 to TLsFilelistView26.

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

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

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

   ResetTreeView    - Reload the TLsDirTreeView.

 3.3 TLsDirTree10
 ----------------

   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.


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

   Unzip FileExpl.zip to any directory, then copy LsFileExplorer26.pas
   and LsFileExplorer26.dcr to a directory that is in the Lib search path.
   (For Delphi 2x users:- please also copy ShellObj.pas, if it's not already
   in your D2 Library path).

 4.1 For Delphi version 2x
 -------------------------

   - Choose Component|Install form the Main Menu
   - From the Install Component dialog, choose Add
   - From Add Module dialog, click Browse button.
   - Navigate to your chosen directory and select LsFileExplorer26.pas,
     then click Open to add it to the Installed Units Box.
   - click OK to install the components.

 4.2 For Delphi versions 3x , 4x  & 5x
 -------------------------------------

   Both components can be added to an existing Package, eg. Samples or
   Delphi User's Components Package in D3, 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 LsFileExplorer26.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 TLsDirTree10 (or TLsDirTreeCombo26) and TLsFileListView26 
components in an application, they must be mutually connected through the use 
of the TLsDirTree10's (or TLsDirTreeCombo26's) 'FileList' property and the 
TLsFileListView25's 'DirTree' property (or 'DirTreeCombo' property if 
TLsDirTreeCombo26 is used). Once they are interconnected, changes in one 
component will be automatically reflected in the other component.

For example, the LsDirTree10 and LsFileListView26 components in your application
are named as LsDirTree101 and LsFileListView261 respectively. You can use Object
Inspector to set LsDirTree101's 'FileList' property to LsFileListView261; likewise, 
set LsFileListView261's 'DirTree' property to LsDirTree101.


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

     5.2.1 TLsDirTree10 and TLsDirTreeCombo26
     ==========================================================================     
     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 TLsFilelistView26
     ==========================================================================
     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 TLsFilelistView26
     ==========================================================================

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

     5.3.1 LsFileListViewPopup26   
     ================================================================
     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 LsDirTreePopUp10
     ================================================================
     Menu Name            Commands / Remarks
     ---------------      -------------------------------------------
     Add Folder           AddNewNode() /Creates a new directory
     Rename Folder                     /Rename an existing directory
     Delete Folder        DeleteNode() /Delete an existing 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 TLsFilelistView26 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.60
 ------------
    - Added a Directory-TreeView component 'TLsDirTree10'.
    - 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 TLsFilelistView26.
    - 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 TLsDirTreeCombo26, and revised ShortCut keys
      in TLsFilelistView26 in order to conform with standard shortcuts
      used by Windows Explorer.
    - Added procedure FindFile to TLsFilelistView26.
    - In LsFilelistView26, 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 TLsDirTreeCombo26, has been SentToBack.
    - Incorporated patches to TLsFilelistView26 to avoid possible AV errors.

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

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