Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8149371
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T14:50:15+00:00 2026-06-06T14:50:15+00:00

i am trying to add small icon to VirtualTreeview in delphi2010 i have ImageList

  • 0

i am trying to add small icon to VirtualTreeview in delphi2010
i have ImageList attached to VirtualTreeview using the property images

procedure TMainFrm.VSTGetImageIndex(Sender: TBaseVirtualTree;
  Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
  var Ghosted: Boolean; var ImageIndex: Integer);
var
  FileInfo: PFileInfoRec;
begin
  if Kind in [ikNormal , ikSelected] then
  begin
    if Column = 0 then
    ImageIndex :=ImageList1.AddIcon(FileInfo.FileIco);
  end;
end;

but after adding the icons look too dark:

screenshot

FileInfo Strucutre (Record with methods) filled whene i load the files so
what i need is just to add the fileico from fileinfo to imagelist and display in treeview

type
  PFileInfoRec= ^TFileInfoRec;
  TFileInfoRec = record
  strict private
    vFullPath: string;
      .
      .
      .
    vFileIco : TIcon;
  public
    constructor Create(const FilePath: string);
    property FullPath: string read vFullPath;
      .
      .
      .
    property FileIco : TIcon  read vFileIco;
  end;

the constructor:

constructor TFileInfoRec.Create(const FilePath: string);
var
  FileInfo: SHFILEINFO;
begin
  vFullPath := FilePath;
    .
    .
    .
  vFileIco        := TIcon.Create;
  vFileIco.Handle := FileInfo.hIcon;
//  vFileIco.Free;
end;

so where is the probleme ? ! thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T14:50:16+00:00Added an answer on June 6, 2026 at 2:50 pm

    Let’s have an image list ImageList1 and assign it to VirtualStringTree1.Images property. Then joining to the previous commenters, before you use FileInfo, assign something to it, like: FileInfo := Sender.GetNodeData(Node), than you can use FileInfo.FileIco. But you should add your icon to the imagelist not in the OnGetImageIndex. You should do it in OnInitNode (if you follow the virtual paradigm, what you should do), than store the index of the added icon in FileInfo. example:

    procedure TForm1.VirtualStringTree1InitNode(Sender: TBaseVirtualTree;
      ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates);
    var
      FileInfo: PFileInfoRec;
    begin
      FileInfo := Sender.GetNodeData(Node);
      //...
      FileInfo.FileIcoIndex := ImageList1.AddIcon(FileInfo.FileIco);
    
    end;
    

    than in onGetImageIndex:

    procedure TMainFrm.VSTGetImageIndex(Sender: TBaseVirtualTree;
      Node: PVirtualNode; Kind: TVTImageKind; Column: TColumnIndex;
      var Ghosted: Boolean; var ImageIndex: Integer);
    var
      FileInfo: PFileInfoRec;
    begin
      FileInfo := Sender.GetNodeData(Node);
      if Kind in [ikNormal , ikSelected] then
      begin
        if Column = 0 then
        ImageIndex :=FileInfo.FileIcoIndex;
      end;
    end;
    

    If it’s not adequate, please post more sample code, to enlighten us about your problem.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to add a small lock icon to a disabled textfield / text
I'm trying to add base, small, and thumbnail images to all of my products
I am trying to add a small border to an icon. The problem is,
I'm trying to add a small shadow to an image, much like the icon
I'm trying to add the following custom element using TinyMCE... <g:plusone size=small callback=plusone_vote></g:plusone> I've
I'm currently trying to add PGP signing support to my small e-mail sending script
I'm trying to add some functionality to dunst, a small notification system. I've never
So I am trying to add an icon to an image, once someone has
I am trying to add some styles in some DataGrid s I have. I
I'm trying to add a small level of security to a site and encode

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.