Never mind, I couldn't find anything yesterday but found some code today
after some carefully worded googling, which appears to work well.


  RGB := ColorToRGB(BackColor);

  if (GetRValue(RGB) + GetGValue(RGB) + GetBValue(RGB)) > 384 then

    Font.Color := clBlack


    Font.Color := clWhite;


From: [] On
Behalf Of Ross Levis
Sent: Tuesday, 7 June 2011 4:06 PM
To: 'NZ Borland Developers Group - Delphi List'
Subject: [DUG] Auto Black or White font colour


I'm hoping someone may have a routine which determines if the font colour
should be black or white depending on the colour of the component.


I have buttons which the user can choose the colour, but black text on a
dark colour can't be seen.



NZ Borland Developers Group - Delphi mailing list
Unsubscribe: send an email to with Subject: 

Reply via email to