Virtual TreeView selection width with toUseExplorerTheme

Viewed 1152

When I use toUseExplorerTheme in TVirtualStringTree.PaintOptions it draws the selection like this:

Illustration of selection with toUseExplorerTheme

Notice that the selection extends from the left side of the control to the position of the rightmost extent of any node caption; the selections are all the same width.

I want it to look as in this image (someone else's project, using Virtual TreeView), where the selection covers only the text of the node caption:

enter image description here

Unless there is a regression in Virtual TreeView (I'm using 5.2.2) then this must be possible, but I cannot find the right combination of options.

Here's my set-up code:

fTree := TVirtualStringTree.Create(Self);
fTree.Parent            := Self;
fTree.Align             := alClient;

fTree.OnGetText         := TreeGetText;
fTree.OnInitNode        := TreeInitNode;
fTree.OnInitChildren    := TreeInitChildren;
fTree.OnChange          := TreeSelectionChange;
fTree.RootNodeCount     := 1;
fTree.DrawSelectionMode := smBlendedRectangle;

fTree.TreeOptions.PaintOptions     := fTree.TreeOptions.PaintOptions
                                      + [toUseExplorerTheme];
fTree.TreeOptions.SelectionOptions := fTree.TreeOptions.SelectionOptions
                                      + [toMultiSelect];
1 Answers
Related