I'm use TVirtualStringTree+toUseExplorerTheme+toThemeAware for beautiful display. But i need change color of selected item and hover item. How can this be done?
Asked
Active
Viewed 189 times
0
-
1I'm not sure I understand... If you tell TVT to use the OS theme, then the colors are defined by the OS. What does your TVT look like, and what would you like it to look like? Add a image snip (no fullscreen though) just enough to show what you mean. – Tom Brunberg Mar 06 '18 at 17:28
-
Nothing easy. You will need to override `PrepareCell` method and color blend the theme drawn selection rectangles. – Victoria Mar 07 '18 at 03:23
1 Answers
0
Thanks to everyone! Solved the problem as follows:
SelectionBlendFactor := 0 toUseExplorerTheme+toThemeAware := False
procedure MyForm.vtLogBeforeItemErase(Sender: TBaseVirtualTree;
TargetCanvas: TCanvas; Node: PVirtualNode; ItemRect: TRect;
var ItemColor: TColor; var EraseAction: TItemEraseAction);
begin
inherited;
if not Assigned(Node) then
Exit;
EraseAction := eaColor;
if not Odd(Node.Index) then
ItemColor := $00FAF7F5
else
ItemColor := vtLog.Color;
if vsSelected in Node.States then begin
if vtLog.Focused then
ItemColor := $00D6B693//$E1B959
else
ItemColor := $00E9E1D8;
end
else
if vtLog.Focused and Assigned(vtLog.HotNode) and (vtLog.HotNode.Index = Node.Index) then begin
ItemColor := $00FBECDC;
end;
end;
And very beautiful all drawing and working.

Петя Васечкин
- 23
- 4
-
The line "SelectionBlendFactor := 0 toUseExplorerTheme+toThemeAware := False" in your answer makes no sense whatever. – MartynA Mar 07 '18 at 13:03
-
Sorry. addition need toUseBlendSelection := True, else selected item separate by columns. – Петя Васечкин Mar 07 '18 at 16:16