Q about ShellTreeView no.2 - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Q about ShellTreeView no.2

DeYoDeYo Posts: 8Member
If I have path saved in string how can I set TShellTreeView to point to this folder. Example:

procedure Button1Click(Sender: TObject)
var
path: string;
begin
path:='c:my documents';
ShellTreeView1.???:=path;
end;

Comments

  • injektiloinjektilo Posts: 113Member
    shellcontrols were under construction in D6, by steve trefethen from the delphi team, and have alot of errors...i know what to change to make your thing work but i dont know how it inflicts other parts of the code, but anyway, here i go:

    open te file ShellCtrls wich contains the code (in Demos), add it to your library path and source path to compile. find the following procedure :

    [code]
    procedure TCustomShellTreeView.SetPathFromID(ID: PItemIDList);
    var
    I: Integer;
    Pidls: TList;
    Temp, Node: TTreeNode;
    begin
    if FUpdating or (csLoading in ComponentState)
    or ((SelectedFolder <> nil) and SamePIDL(SelectedFolder.AbsoluteID, ID)) then Exit;
    FUpdating := True;
    Items.BeginUpdate;
    try
    Pidls := CreatePIDLList(ID);
    try
    Node := Items[0];
    for I := 0 to Pidls.Count-1 do
    begin
    Temp := FolderExists(Pidls[I], Node);
    if Temp <> nil then
    begin
    Node := Temp;
    Node.Expand(False);
    end;
    end;
    Node := FolderExists(ID, Node);
    Selected := Node;
    if Assigned(Node) then
    begin
    if Assigned(FListView) then
    FListView.TreeUpdate(TShellFolder(Node.Data).AbsoluteID);
    if Assigned(FComboBox) then
    FComboBox.TreeUpdate(TShellFolder(Node.Data).AbsoluteID);
    end;
    finally
    DestroyPIDLList(Pidls);
    end;
    finally
    Items.EndUpdate;
    FUpdating := False;
    end;
    end;
    [/code]

    whenever you set the ShellView.Path property this procedure is called but the first line contains an error and causes to Exit without an update, so you could comment it out.

    to change path with the new code use this:
    [code]
    ShellView1.Path := Edit1.Text
    [/code]


Sign In or Register to comment.