如何修改TVirtualStringTree中的焦点框颜色?

发布于 2024-10-31 20:13:17 字数 116 浏览 3 评论 0原文

我需要修改 TVirtualStringTree 的焦点框边框颜色, 就像这张图片:

从灰色到红色

I need to modify the focus-box's border color of TVirtualStringTree,
just like this pic:

from gray color to red color

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

难理解 2024-11-07 20:13:17

您无法控制虚线焦点矩形的颜色。这是通过反转所绘制内容的颜色自动确定的。操作系统提供(并且树控件使用)相应的 API。 (如果需要,您可以编辑源代码并将对 DrawFocusRect 的调用替换为您自己的函数。)

如果您正在谈论整个节点的颜色,请首先检查以确保 < code>toUseBlishedSelection 绘制选项按照您想要的方式设置。它默认关闭,但由于在项目周围拖动框时它使选择矩形看起来很酷,因此您可能在没有意识到它对普通选定节点的作用的情况下打开了它。

如果不是这样,则调整树控件的 Colors 属性中的值之一,可能是 FocusedSelectionColorUnfocusedSelectionColor。但请不要轻易做出这样的改变;用户已通过操作系统选项选择了选择颜色,因此您可能不应该更改它。如果您确实使用不同的颜色,请确保文本相对于您选择的任何新颜色仍然可读。

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 either FocusedSelectionColor or UnfocusedSelectionColor. 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.

花海 2024-11-07 20:13:17

您可以将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 use OnBeforeCellPaint).

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文