Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

ShellTreeView / ShellListView Components

Status
Not open for further replies.

gp4

Technical User
Sep 27, 2002
30
AU
Hi,
I'm using Delphi 7 and trying to use the components:
ShellTreeView and ShellListView

however its not clear how you can obtain the filename/path for example when selecting an object from the listview.
Does any one have any clues?

Thanks
 
Try using the path property.

So, for example, if your form contains a TShellTreeView, a TButton and a TEdit and you want the currently selected path in the TShellTreeView to appear in the TEdit when you click on the button your code would look something like:
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := ShellTreeView1.Path;
end;


Andrew
Hampshire, UK
 
Thanks for your response.
Do you know what property to use from ShellListView to get the name of the selected file.

Thanks
 
If you want to get the path from a ShellListView component then I think you need to have a ShellTreeView component also on the form. It doesn't have to be visible if you don't want it to take up any of your form's real estate.

At design time set the ShellTreeView property of your ShellListView component to the name of your ShellTreeView component.

Then it is simply a matter of referring to the path property once again:
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := ShellListView1.ShellTreeView.Path;
end;
The ShellComboBox component has properties called ShellListView and ShellTreeView so that you can link all three components together.


Andrew
Hampshire, UK
 
Hi,
I tried the suggestion above however this only shows the path of the object you select in the ShellListView component. I am also trying to obtain the filename of the object selected in this view.
Any ideas?

Thanks
 
I suggest you take a look at the source code for these components but I found that they don't make easy reading.

Anyway, if you want the full path and file name of the selected file when you click Button1 use code like:
Code:
procedure TForm1.Button1Click(Sender: TObject);
begin
  Edit1.Text := ShellListView1.SelectedFolder.PathName;
end;

Andrew
Hampshire, UK
 
I tried:
procedure TForm1.Button1Click(Sender: TObject);
begin
Edit1.Text := ShellListView1.SelectedFolder.PathName;
end;

however the Pathname property does not exist.

Where is the sourcecode for these components located?
Thanks
 
I'm using Delphi 7 (Professional).

The source code is in the ShellCtrls unit which on my (default) configuration is in c:\Program Files\Borland\Delphi7\Demos\ShellControls



Andrew
Hampshire, UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top