如何修改TVirtualStringTree中的焦点框颜色?
我需要修改 TVirtualStringTree 的焦点框边框颜色, 就像这张图片:
I need to modify the focus-box's border color of TVirtualStringTree,
just like this pic:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您无法控制虚线焦点矩形的颜色。这是通过反转所绘制内容的颜色自动确定的。操作系统提供(并且树控件使用)相应的 API。 (如果需要,您可以编辑源代码并将对
DrawFocusRect
的调用替换为您自己的函数。)如果您正在谈论整个节点的颜色,请首先检查以确保 < code>toUseBlishedSelection 绘制选项按照您想要的方式设置。它默认关闭,但由于在项目周围拖动框时它使选择矩形看起来很酷,因此您可能在没有意识到它对普通选定节点的作用的情况下打开了它。
如果不是这样,则调整树控件的
Colors
属性中的值之一,可能是FocusedSelectionColor
或UnfocusedSelectionColor
。但请不要轻易做出这样的改变;用户已通过操作系统选项选择了选择颜色,因此您可能不应该更改它。如果您确实使用不同的颜色,请确保文本相对于您选择的任何新颜色仍然可读。You can't control the color of the dotted focus rectangle. That's determined automatically by inverting the color of whatever it's drawn on. The OS provides — and the tree control uses — an API for that. (You could edit the source code and replace calls to
DrawFocusRect
with your own function, if you want.)If you're talking about the color of the whole node, then first check to make sure the
toUseBlendedSelection
paint option is set the way you want it. It defaults off, but since it makes the selection rectangle look cool when dragging a box around items, you might have turned it on without realizing what it does to ordinary selected nodes, too.If that's not it, then adjust one of the values in the tree control's
Colors
property, probably eitherFocusedSelectionColor
orUnfocusedSelectionColor
. But please don't make such a change lightly; the user has chosen the selection color through the OS options, so you probably shouldn't change it. If you do use a different color, make sure the text is still readable against whatever new color you select.您可以将treeview的选项
toHideFocusRectangle
设置为true,并在多个绘制事件之一中自行绘制焦点矩形(基本上使用OnBeforeCellPaint
就足够了)。You can set treeview's option
toHideFocusRectangle
to true and paint your focus rectangle by yourself in one of several paint events (basically it is enough to useOnBeforeCellPaint
).