How to modify the focus-box color in TVirtualStringTree?
I need to modify the focus-box's border color of TVirtualStringTree, just like this pic:
开发者_JAVA百科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.
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
).
精彩评论