//*******************************************************
//*       TFolderTree Component for Delphi 2.0          *
//*       by Elliott Shevin, Oak Park, Mich. USA        *
//*       June, 1999                                    *
//*       email: shevine@aol.com                        *
//*                                                     *
//*       A visual component that displays a folder     *
//*       tree similar to the left pane of Windows      *
//*       Explorer. There are many of these for later   *
//*       versions of Delphi, but for D2 I had to roll  *
//*       my own.                                       *
//*       I have no idea how well this will work with   *
//*       later versions, and recommend you try one of  *
//*       the several fine freeware components for the  *
//*       same purpose that you can find where you got  *
//*       this.                                         *
//*                                                     *
//*       This component is freeware. Use it in good    *
//*       health, no restrictions, but I will           *
//*       appreciate an acknowledgment. I, in turn,     *
//*       thank Tom Deprez, from whose CDEvents compo-  *
//*       nent some of this code was adapted.           *
//*                                                     *
//*       This release (1.1) includes a bug couple of   *
//*       bug fixes (it arranges folders within the     *
//*       desktop under "My Computer" instead of above  *
//*       it); and avoids the addressing error which    *
//*       occured when the user clicked on an expand    *
//*       button with no item selected).                *
//*       AND it solves the problem of the interminable *
//*       interval between the component creation and   *
//*       its appearance (yea!). Last, when you drop it *
//*       on a form, it will jump to where the mouse    *
//*       is pointing.                                  *
//*******************************************************

Just install the component as you usually do. As written,
it installs to the Customn tab of the component palette.

You'll find a sample project included.

TFolderTree shares most methods and properties with TTreeView.
Here are the more important differences.

Published properties:
    Directory     : (string) the complete directory path (minus the
                    trailing backslash) corresponding to the currently 
                    selected node. If the user selects the Desktop,
                    this is the corresponding directory. If the user 
                    selects My Computer, it's null.
    DisplayMode   : (enumerated) controls whether nodes are displayed
                    in uppercase, lowercase, or as is.

Methods:
    function SetDirectory(path : string) : TTreeNode;
                  Finds the deepest node in the structure corresponding 
                  to "path", selects that node, and returns it. The 
                  returned node can be passed to GetPath (below) to 
                  obtain the complete path corresponding to the node.

    GetPath (Node : TTreeNode) : string;
                  Returns the path corresponding to the node passed.

Notes:
    If the component is placed on a form that isn't visible, it some-
    times behaves strangely when the form finally becomes visible; the
    "expand" boxes don't appear next to those nodes that should
    have them.
    I don't know why, nor whether it will also happen if the component 
    isn't initially visible on a form that is. My workaround has been 
    to create the TFolderTree as part of a FormShow event handler.

    There are threads that detect when the user opens or closes 
    the CD drive, and when the directory structure changes for 
    nodes displayed at the time. The tree responds to such 
    events.

    Another difficulty is that changes to the CD drive aren't 
    reflected accurately; the first time a CD is removed isn't 
    indicated. And, if (say) Explorer is also running, this 
    component's display shows the CD is present when it's absent,
    and vice versa. Advice, anyone?

    As for changes in directory structures: the node containing 
    the changed structure is collapsed and re-expanded.

I'll be happy to hear your comments and suggestions at: shevine@aol.com.