ShellTreeView Control

Properties

ShellListView

If a ShellListView exists on the form then you can set this property to point to that control so that it will be linked to the current ShellTreeView control.

ShellComboBox

If a ShellComboBox exists on the form then you can set this property to point to that control so that it will be linked to the current ShellTreeView control.

Path

Only the ShellTreeView has a Path property. Use this to provide an exact path to a file, as in the Backup example below.

Example: Linking Shell Controls

In this example three types of shell control, a ShellComboBox, a ShellTreeView and a ShellListView are linked so a change in one leads to a change in the others.

(The button displays the current path of ShellTreeView.)

Example: Backup Path

The example below uses the Path property of the ShellTreeView to provide part of the complete path for a backup procedure.

  1. First, the dateseparator is changed from '/' to '_' as '/' is already reserved in a path to represent a change of folder.
  2. Second, the current date is copied into a string (not essential, this could be done in copyfile.
  3. Third, the copyfile() procedure is called to copy an existing file to a new file. The new file name is made up of four parts:

procedure TBackUpForm.ButtonClick(Sender: TObject);
var strdate, ExistingFile, NewFile : string;
begin
 dateseparator := '_';        
//change date separator to avoid clash with file separator
 ExistingFile:= 'dbase.mdb'; 
//the name of your database file
 strdate := datetostr(now);
 NewFile := IncludeTrailingBackslash(ShellTreeView1.selectedfolder.pathname) + strdate + ExtractFileName (ExistingFile);
 copyfile (PChar(ExistingFile), PChar(NewFile), false);
 messagebox(handle,'Your data has been sucessfully backed up.', 'Backup successful', MB_OK + MB_ICONINFORMATION);
 dateseparator := '/';        
//restore date separator symbol
end;

For a sample application see the DirectoryOutline pages.

Back to Tutorial

Back to Palette List