[DUG] Auto Black or White font colour
Ross Levis
ross at stationplaylist.com
Tue Jun 7 17:26:12 NZST 2011
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
else
Font.Color := clWhite;
From: delphi-bounces at delphi.org.nz [mailto:delphi-bounces at delphi.org.nz] 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.
Cheers.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://listserver.123.net.nz/pipermail/delphi/attachments/20110607/3871e436/attachment.html
More information about the Delphi
mailing list