虚拟TreeView选择宽度与toUseExplorerTheme [英] Virtual TreeView selection width with toUseExplorerTheme
问题描述
当我在 TVirtualStringTree.PaintOptions
中使用 toUseExplorerTheme
时,会绘制如下选项:
请注意,选择从控件的左侧扩展到任何节点标题的最右边的位置;选择都是相同的宽度。
我希望它看起来像这个图像(。我在 此问题中建议的声明
应该是:
procedure DrawBackground(State:Integer);
begin
//如果完整的行选择被禁用,或者在GisconsOptions中放置到GridExtensions,则将选择
//绘制到InnerRect中,否则放入RowRect
(如果没有)(toFullRowSelect然后
DrawThemeBackground(Theme,PaintInfo.Canvas.Handle,TVP_TREEITEM,State,InnerRect,nil)
else
DrawThemeBackground(Theme,PaintInfo),(在FOptions.FSelectionOptions中)或(toGridExtensions in FOptions.FMiscOptions) .Canvas.Handle,TVP_TREEITEM,State,RowRect,nil);
结束
同样适用于下一个嵌套过程 DrawThemedFocusRect
。现在,该修复程序已提交给 修订版r587
,所以请更新您的虚拟树视图。感谢 @joachim 进行合作!
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];
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!
这篇关于虚拟TreeView选择宽度与toUseExplorerTheme的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!