2

i'm using VirtualTreeView (as a grid - in Delphi XE7) in my app and i also chose to use the Carbon VCL style. The problem arise because i need to color some rows according some status on each line, and the font color keep staying white even when i use a light color on a line. So it is impossible to read the data. When i use the Iceberg Classico style, this issue do not occurs.

So basically, i can change my set of rows color according to the style selected, it is one solution. But i'm looking for a way to modify the font color according to the row color background?

I'm doing the colorization code inside the event: BeforeCellPaint and i tried to modify the font color without any success.

Any idea?

LU RD
  • 34,438
  • 5
  • 88
  • 296
  • 1
    Please post your colorization code. – LU RD Jun 04 '15 at 16:43
  • 1
    Btw, i found a library that helps a lot on this subject: // unit for the VCL Styles Utils // https://github.com/RRUZ/vcl-styles-utils/ TargetCanvas.Brush.Color := aColor; if TStyleManager.ActiveStyle.Name = 'Carbon' then TCustomStyleExt(TStyleManager.ActiveStyle).SetStyleFontColor(sfTreeItemTextNormal, clBlack) else TCustomStyleExt(TStyleManager.ActiveStyle).SetStyleFontColor(sfTreeItemTextNormal, aFontColor); TargetCanvas.FillRect(CellRect); With this i can change the font color. – Laurent Saragosti Jun 05 '15 at 14:27
  • 1
    Post that as an answer :-) – LU RD Jun 05 '15 at 14:50

1 Answers1

1

i found a library that helps a lot on this subject:

// unit for the VCL Styles Utils 
// github.com/RRUZ/vcl-styles-utils 

TargetCanvas.Brush.Color := aColor; 
if TStyleManager.ActiveStyle.Name = 'Carbon' then
   TCustomStyleExt(TStyleManager.ActiveStyle).SetStyleFontColor(sfTreeItemTextNorma‌​l, clBlack) 
else
   TCustomStyleExt(TStyleManager.ActiveStyle).SetStyleFontColor(sfTreeItemTextNorma‌​l, aFontColor); 
TargetCanvas.FillRect(CellRect); 

With this i can change the font color.

Laurent

Ken White
  • 123,280
  • 14
  • 225
  • 444
  • See this question for an algorithm for choosing light or dark font color based on background: http://stackoverflow.com/questions/1855884/determine-font-color-based-on-background-color – René Hoffmann Jun 15 '15 at 10:25