I just discovered that using the Option toUseExplorerTheme allows to produce a nice selection rectangle for a VirtualStringTree. However, if the Option toGridExtensions is set and there are several columns in the tree, the vertical border of the selection is not drawn for the inner cells, and the rounded corners are missing as well. Only the outermost edges and corners of the left- and right-most columns are drawn correctly. It looks as if the selection rectangle is drawn between the outermost columns and the background of the non-selected columns is just drawn over the selection rectangle.
Turning off the toGridExtensions results in a correct selection rectangle, but I prefer to have it on because a cell can only be selected by clicking on the text in the standard mode (not by clicking on the empty space next to the text).
The issue occurs with Delphi 7 and XE2, and probably also with other versions.
To reproduce add a TVirtualStringTree to a form, show the header, add several columns to the header, and activate the options toGridExtensions (MiscOptions), toUseExplorerTheme (PaintOptions), toExtendedFocus (SelectionOptions), run the program and click on any cell.
In my view it's a bug, because who would like to have a selection like this:
To fix it in a Virtual Tree View code (in my case v.5.1.4), go to the
TBaseVirtualTree.PrepareCell
method (in my case line 25802) and check this nested procedure code (comments are mine):To fix this issue modify the code this way:
And you'll get a selection like this:
The same applies also to the next
DrawThemedFocusRect
nested procedure.I have reported this problem as
Issue 376
, which is fixed inrevision r587
.