2

I have an issue with VirtualTreeView component on Windows 7. I added a TVirtualStringTree and used OnGetImageIndex event to assign ImageIndex which is always in debugger non-zero value.

VirtualStringTree uses a TImageList with 16x16 icons as Images property.

On Windows XP it works properly and on Windows 7 it overlaps icon with index 0 from TImageList on top of a normal icon. I am running the same program on Windows 7 as on XP so the code is identical, but the drawing is different.

This image illustrates the issue:

virtualtreeview issue

The gray triangle icon has index of 0 and folder icon has index of 5.

Is this a bug in VirtualStringTree? Can I somehow avoid this?

I am using the latest VirtualTreeView version from repository.

Community
  • 1
  • 1
Coder12345
  • 3,431
  • 3
  • 33
  • 73
  • Show the code of your OnGetImageIndex handler. – Ondrej Kelle Nov 17 '11 at 17:41
  • 2
    In that case, you may be missing the code which takes into consideration the `Kind: TVTImageKind` parameter. `ikOverlay` might be in effect. This alone would not explain your symptoms but it is an unusual use case. – Ondrej Kelle Nov 17 '11 at 17:45
  • I think you're right... I just looked in other piece code I do have a handler for: if (Kind == ikNormal || Kind == ikSelected) that assigns the value only if the former is true (otherwise it is -1) and that one appears to draw normally. – Coder12345 Nov 17 '11 at 17:53

1 Answers1

8

In your OnGetImageIndex event handler, pay attention to the Kind: TVTImageKind parameter. Assign ImageIndex as required (typically, this is only for ikNormal and ikSelected values), otherwise assign -1.

For example, assigning a valid image index when Kind has the value of ikOverlay will cause an overlay image to be drawn over the normal image. (Which may be related to your problem.)

Ondrej Kelle
  • 36,941
  • 2
  • 65
  • 128
  • Actually there is no need to assign ImageIndex explicitly because by default it is already -1 so simple check for ikNormal/ikSelected is enough. – Coder12345 Nov 18 '11 at 01:51