Virtual TreeView selection width with toUseExplorerTheme

a 夏天 提交于 2019-11-30 15:13:54

问题


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

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:

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:


Sorry, that was my fault. The statement I've suggested in this issue should have rather be:

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 also to the next nested procedure DrawThemedFocusRect. The fix is now commited to the revision r587, so please update your Virtual Treeview. Thanks to @joachim for cooperation!



来源:https://stackoverflow.com/questions/20637534/virtual-treeview-selection-width-with-touseexplorertheme

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!