Lazarus

Free Pascal => Beginners => Topic started by: BIT on December 29, 2017, 02:39:49 pm

Title: TreeView Files Directory icon
Post by: BIT on December 29, 2017, 02:39:49 pm
Не правильно выводит иконку директории помогите картинку прикрепил

Not correctly displays the icon directory help picture attached 

Code: Pascal  [Select][+][-]
  1. FilePathToTreeNode(TreeView1, nil, ExtractFileDir(OpenDialog1.FileName) + '\', True);
Code: Pascal  [Select][+][-]
  1. //Функция Вывод каталога в TreeView1
  2. procedure TForm1.FilePathToTreeNode(aTreeView: TTreeView; aRoot: TTreeNode;
  3.   Path: string; Recurse: boolean);
  4. var
  5.   NewNode: TTreeNode;
  6.   SRec: TSearchRec;
  7. begin
  8.   if FindFirst(Path + '*.*', SysUtils.faAnyFile, SRec) = 0 then
  9.     repeat
  10.       if (sRec.Name = '.') or (sRec.Name = '..') then
  11.         Continue;
  12.       if SRec.Name <> 'Projects.luse' then
  13.       begin
  14.         //Не отоброжаем фай конфигурации
  15.         NewNode := aTreeView.Items.AddChild(aRoot, SRec.Name);
  16.          NewNode.HasChildren := false;
  17.       end;
  18.       if Recurse and ((srec.Attr and SysUtils.faDirectory) <> 0) then
  19.       begin
  20.  
  21.              FilePathToTreeNode(aTreeView, NewNode, Path + srec.Name + '\', True);
  22.  
  23.         //папка
  24.         NewNode.ImageIndex := 1108;
  25.         NewNode.SelectedIndex := 1108;
  26.  
  27.       end
  28.       else
  29.       begin
  30.  
  31.         //Файл
  32.         NewNode.ImageIndex := 804;
  33.         NewNode.SelectedIndex := 785;
  34.       end;
  35.  
  36.  
  37.     until FindNext(SRec) <> 0;
  38.  
  39. end;                            
Title: Re: TreeView Files Directory icon
Post by: wp on December 29, 2017, 02:52:13 pm
Please don't link to data on external servers. Your links are blocked on my system as being malware.
Title: Re: TreeView Files Directory icon
Post by: taazz on December 29, 2017, 05:24:48 pm
Can you please post the srec.Attr for nwindow? Is the "if Recurse and ((srec.Attr and SysUtils.faDirectory) <> 0) then" true or false?
As a side note the if is wrong.
Title: Re: TreeView Files Directory icon
Post by: BIT on December 29, 2017, 05:41:35 pm
Can you please post the srec.Attr for nwindow? Is the "if Recurse and ((srec.Attr and SysUtils.faDirectory) <> 0) then" true or false?
As a side note the if is wrong.
Если я вас понял дело не в название папки  в цикле перебора папок в коде вроде все хорошо в чем причина непонятно((

If I understood you it is not the name of a folder in a loop to iterate through folders in code like all good why is not clear((
Title: Re: TreeView Files Directory icon
Post by: BIT on December 29, 2017, 05:43:30 pm
Can you please post the srec.Attr for nwindow? Is the "if Recurse and ((srec.Attr and SysUtils.faDirectory) <> 0) then" true or false?
As a side note the if is wrong.

The second pass the search folder such resultat
Title: Re: TreeView Files Directory icon
Post by: ASerge on December 30, 2017, 10:20:16 am
Not correctly displays the icon directory help picture attached 
When SRec.Name = 'Projects.luse' then NewNode is undefined.
Title: Re: TreeView Files Directory icon
Post by: BIT on December 30, 2017, 03:18:56 pm
Not correctly displays the icon directory help picture attached 
When SRec.Name = 'Projects.luse' then NewNode is undefined.

Yes exactly this was the problem, thank you!
TinyPortal © 2005-2018