Recent

Author Topic: [SOLVED] VirtualStringTree icons  (Read 529 times)

Pe3s

  • Hero Member
  • *****
  • Posts: 547
[SOLVED] VirtualStringTree icons
« on: March 04, 2023, 06:33:26 pm »
Hello forum users, I wrote a code that displays icons in VST. How can I modify the code to add a different icon to the child?
Code: Pascal  [Select][+][-]
  1. procedure TForm1.VSTGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);
  2. begin
  3.   case Kind of
  4.     ikNormal, ikSelected:
  5.       case Column of
  6.         0: ImageIndex:= 0;
  7.       end;
  8.    end;
  9. end;
  10.  
« Last Edit: March 04, 2023, 08:16:57 pm by Pe3s »

paweld

  • Hero Member
  • *****
  • Posts: 1187
Re: VirtualStringTree icons
« Reply #1 on: March 04, 2023, 06:56:50 pm »
something like this: 
Code: Pascal  [Select][+][-]
  1. procedure TForm1.VSTGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode;  
  2.   Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);  
  3. var  
  4.   nl: Integer;  
  5. begin  
  6.   nl := Sender.GetNodeLevel(Node);  
  7.   case nl of  
  8.     0:  ImageIndex := 0;  //root  
  9.     1..3: ImageIndex := 1;  //child level between 1 and 3  
  10.     4..6: ImageIndex := 2;  
  11.     //etc.  
  12.   end;  
  13. end;
  14.  
Best regards / Pozdrawiam
paweld

Pe3s

  • Hero Member
  • *****
  • Posts: 547
Re: VirtualStringTree icons
« Reply #2 on: March 04, 2023, 07:14:21 pm »
Everything would be ok if there were no duplicate icons

paweld

  • Hero Member
  • *****
  • Posts: 1187
Re: VirtualStringTree icons
« Reply #3 on: March 04, 2023, 07:23:31 pm »
You need to add a column condition 
Code: Pascal  [Select][+][-]
  1. procedure TForm1.VSTGetImageIndex(Sender: TBaseVirtualTree; Node: PVirtualNode;  
  2.   Kind: TVTImageKind; Column: TColumnIndex; var Ghosted: Boolean; var ImageIndex: Integer);  
  3. var  
  4.   nl: Integer;  
  5. begin  
  6.   if Column = 0 then  
  7.   begin    
  8.     nl := Sender.GetNodeLevel(Node);  
  9.     case nl of  
  10.       0:  ImageIndex := 0;  //root  
  11.       1..3: ImageIndex := 1;  //child level between 1 and 3  
  12.       4..6: ImageIndex := 2;  
  13.       //etc.  
  14.     end;  
  15.   end;  
  16. end;
  17.  
Best regards / Pozdrawiam
paweld

Pe3s

  • Hero Member
  • *****
  • Posts: 547
Re: VirtualStringTree icons
« Reply #4 on: March 04, 2023, 08:16:40 pm »
@paweld Thank you :)

 

TinyPortal © 2005-2018