Tuesday 2 April 2013

Retrieving a system color

I had a problem recently and needed to set a font colour depending what was set as a system colour, in Delphi this ended up being very easy. To get say the highlight colour just do the following:

GetSysColor(COLOR_HIGHLIGHT)

This returns the colour as a TColor, I then used this value in a previous function to determine whether is was light or dark and then set the font colour accordingly. This will require 'Windows' and 'Graphics' in the uses clause. The 'color_highlight' is a constant, go to where it is declared in the windows unit to see the other options.


No comments:

Post a Comment