Recent

Author Topic: ShellCtrls & root property  (Read 5916 times)

warcode

  • New Member
  • *
  • Posts: 36
ShellCtrls & root property
« on: March 18, 2010, 08:51:48 pm »
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

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 1927
Re: ShellCtrls & root property
« Reply #1 on: March 18, 2010, 10:08:40 pm »
I had the same problem and wrote a procedure for my purpose:

Code: [Select]
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;

Do you mean this?

warcode

  • New Member
  • *
  • Posts: 36
Re: ShellCtrls & root property
« Reply #2 on: March 23, 2010, 03:51:39 pm »
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

 

TinyPortal © 2005-2018