Recent

Author Topic: TreeView Files Directory icon  (Read 2078 times)

BIT

  • Jr. Member
  • **
  • Posts: 55
TreeView Files Directory icon
« 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;                            
« Last Edit: December 29, 2017, 03:18:02 pm by BIT »

wp

  • Hero Member
  • *****
  • Posts: 5294
Re: TreeView Files Directory icon
« Reply #1 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.
Lazarus trunk / fpc 3.0.4 / all 32-bit on Win-10

taazz

  • Hero Member
  • *****
  • Posts: 5363
Re: TreeView Files Directory icon
« Reply #2 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.
« Last Edit: December 29, 2017, 05:28:44 pm by taazz »
Good judgement is the result of experience … Experience is the result of bad judgement.

OS : Windows 7 64 bit
Laz: Lazarus 1.4.4 FPC 2.6.4 i386-win32-win32/win64

BIT

  • Jr. Member
  • **
  • Posts: 55
Re: TreeView Files Directory icon
« Reply #3 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((

BIT

  • Jr. Member
  • **
  • Posts: 55
Re: TreeView Files Directory icon
« Reply #4 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

ASerge

  • Hero Member
  • *****
  • Posts: 1031
Re: TreeView Files Directory icon
« Reply #5 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.

BIT

  • Jr. Member
  • **
  • Posts: 55
Re: TreeView Files Directory icon
« Reply #6 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!