Forum > LCL

ShellCtrls & root property

(1/1)

warcode:
Hi all

i made a small application thats using a ShellTreeView, i dont understand why we can't not set the root property of this nice components. i dont know if it's realy the root property that i need if i wanna highlight a variable path

Ex

root
   dir1
   dir2
      dir3
      dir4
   dir5
   dir6

If i wanna highlight dir3 what i need to make ?

Thanks for the help
Christian F



       

theo:
I had the same problem and wrote a procedure for my purpose:


--- Code: ---Procedure ShellTreeViewSetTextPath(STV:TShelltreeview; Path:String);
Var Str: TStringList;
  ANode: TTreeNode;
  i: integer;
Begin
  If Not DirectoryExistsUTF8(Path) Then Exit;

  Str := TStringList.Create;
  Str.Delimiter := PathDelim;
  Str.DelimitedText := Path;

  For i:=Str.Count-1 Downto 0 Do
    If Str[i]='' Then Str.Delete(i);

  {$ifdef windows}
    Str[0]:=Str[0]+PathDelim;
  {$endif}

  STV.BeginUpdate;
  ANode := STV.TopItem;

  For i:=0 To Str.Count-1 Do
    Begin
      While (ANode<>Nil) And (ANode.Text<>Str[i]) Do
        Begin
          ANode := ANode.GetNextSibling;
        End;
      If Anode<>Nil Then
        Begin
          Anode.Expanded := True;
          ANode.Selected := True;
          Anode := ANode.GetFirstChild;
        End
      Else
       begin
       str.free;
       STV.EndUpdate;
       Exit;
       end;
    End;
  str.free;
  STV.EndUpdate;
End;

--- End code ---

Do you mean this?

warcode:
Hi theo

yes it's exacly what i need, i got the latest svn version of ShellCtrls  here http://svn.freepascal.org/cgi-bin/viewvc.cgi/trunk/lcl/shellctrls.pas?root=lazarus&view=log

It look c:\ are converted to c: so you function dont work with the new svn change ?
it is a fast way to make it work again :)

Thanks for your support

Christian F

Navigation

[0] Message Index

Go to full version