Discussion:
Disabled Button Colors
(too old to reply)
Jay Michael
2003-07-24 18:11:53 UTC
Permalink
I am designing applications using MS VS.NET, and I am
trying to locate information on the default colors the
system uses to color the various components.

I have learned that there are certain "SystemColors" such
as Control and ControlText that the system defines using
the current color scheme that the user has chosen.

However, I can find nothing in the KnownColors enumeration
that defines what colors are used to "gray out" the text of
disabled buttons. I have several buttons on my application
that use customized Paint methods to draw their own
graphics, which are side by side with ones that simply use
the Button control's built-in Text property. The
customized Paint method does not automatically gray out the
graphics when the Button is disabled. I have tried to
determine an algorithm that the system uses to determine
the gray value (such as averaging the ForeColor and
BackColor), but it is not that simple. There are seemingly
five choices of control color (ranging from ControlDarkDark
to ControlLightLight), which all create a different sort of
grayed out text, with the middle value (Control) strangely
producing the lightest version of grayed out text. Using a
custom color for the control also seems to taint the grayed
out text in some fashion that I have yet to determine.

I am holding off on simply not using the Text property and
using a custom text graying algorithm for when the buttons
are disabled, but this seems heavy handed. I would much
prefer to discover what the system is doing automatically
and mimick it.

There is also another minor additional related problem,
which is figuring out what color the system uses to add an
offset highlight to make the grayed out text seem indented
slightly.

Any help would be appreciated, thanks!

Jay Michael
***@flash.net
krlll
2003-07-24 21:00:28 UTC
Permalink
Post by Jay Michael
I am designing applications using MS VS.NET, and I am
trying to locate information on the default colors the
system uses to color the various components.
Check out the GetSysColor( ) WinAPI function. This will
retrieve any color from the current color scheme. The
MSDN documentation has a list of the possible system
colors, but the one you want for grayed-out text would
be COLOR_GRAYTEXT

i.e. GetSysColor(COLOR_GRAYTEXT) will return the
color value that your code should use to draw the text.

Drawing that "etched" gray text is almost as easy. Just
use COLOR_3DHIGHLIGHT to draw the text at
coordinates (x,y) and then draw it again at (x-1, y-1)
using COLOR_3DSHADOW.

Loading...