TVirtualStringTree - How to change the [-] / [+] buttons?

How can I use my own custom buttons (images) to replace the default [-] / [+] buttons in VST?
Instead, I want to use arrows ( enter image description here , enter image description here ), but also support RTL bidi mode ( enter image description here , enter image description here )

edit: I know the style of bsTriangle (ButtonStyle). This does not apply to RTL. I want to use my own images.

+6
source share
3 answers

Are these images usually not in Windows Vista and Windows 7? The tree control should automatically receive them on those systems when you have themes.

An easy way to get something close to this is to simply set the ButtonStyle property to bsTriangle . However, these will not only be the images shown in the question. The minus arrow will point straight down, not diagonally, and the plus arrow will be solid, not the outline.

You can provide your own bitmap. Change the VT_XPBUTTONMINUS and VT_XPBUTTONPLUS resources to whatever images you want, and set the ButtonFillMode property to fmShaded .

I do not see the possibility of changing the image based on the bi-di mode. You can create a PaintNodeButton class that overrides PaintNodeButton and then draws whatever you want. Copy the placement code from the parent class.

+9
source

IIRC you get it by including toUseExplorerTheme in PaintOptions. However, this also changes the look of the selection (for the better IMNSHO) and, possibly, more.

For example, if I drop TVirtualStringTree on the form and add the following event handlers:

 procedure TForm1.FormCreate(Sender: TObject); begin VT.RootNodeCount := 10; VT.TreeOptions.PaintOptions := VT.TreeOptions.PaintOptions + [toUseExplorerTheme]; VT.OnInitNode := VTInitNode; VT.OnInitChildren := VTInitChildren; end; procedure TForm1.VTInitChildren(Sender: TBaseVirtualTree; Node: PVirtualNode; var ChildCount: Cardinal); begin ChildCount := 3; end; procedure TForm1.VTInitNode(Sender: TBaseVirtualTree; ParentNode, Node: PVirtualNode; var InitialStates: TVirtualNodeInitStates); begin Include(InitialStates, ivsHasChildren); end; 

I get screenshot with triangular markers

Edit: Unfortunately, setting Form1.BiDiMode to bdRightToLeft gives screenshot with wrong triangular markers on my German Windows 7. I don’t know if it works better in Arabic or Hebrew.

+7
source

See the ButtonStyle property. Not sure if this applies to RTL bidi mode.

+1
source

Source: https://habr.com/ru/post/915997/


All Articles