Virtual TreeView selection width using toUseExplorerTheme

When I use toUseExplorerTheme in TVirtualStringTree.PaintOptions , it draws the selection as follows:

Illustration of selection with toUseExplorerTheme

Note that the selection continues from the left side of the control to the position of the rightmost degree of any node header; the choice is the same width.

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

enter image description here

If there is no regression in Virtual TreeView (I am using 5.2.2), this should be possible, but I cannot find the right combination of parameters.

Here is my setup 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]; 
+6
source share
1 answer

Sorry, that was my fault . The statement I suggested in this issue should be sooner:

 procedure DrawBackground(State: Integer); begin // if the full row selection is disabled or toGridExtensions is in the MiscOptions, draw the selection // into the InnerRect, otherwise into the RowRect if not (toFullRowSelect in FOptions.FSelectionOptions) or (toGridExtensions in FOptions.FMiscOptions) then DrawThemeBackground(Theme, PaintInfo.Canvas.Handle, TVP_TREEITEM, State, InnerRect, nil) else DrawThemeBackground(Theme, PaintInfo.Canvas.Handle, TVP_TREEITEM, State, RowRect, nil); end; 

The same applies to the following DrawThemedFocusRect nested procedure. The fix is ​​now tied to revision r587 , so please update your Virtual Treeview. Thanks to @joachim for collaboration!

+6
source

All Articles