For something like this, Reference Source is your friend. If you follow down through the calls, you'll see that the System.Windows.Forms.Button
class eventually calls the ButtonBaseAdapter.DrawText
method to perform the actual drawing of the text on the button. The call stack looks like this:
System.Windows.Forms.ButtonBase.OnPaint
System.Windows.Forms.ButtonBase.PaintControl
- The
PaintControl
method calls Adapter.Paint
. Adapter
is a property which returns the current button's drawing adapter. The adapter it returns depends on the style (viz. flat, popup, standard). If it's a standard style button, then it calls the Button.CreateStandardAdapter
method which returns a ButtonStandardAdapter
, so that's the one which will be used by the PaintControl
method. The ButtonStandardAdapter.Paint
method is implemented by its base class, though, so that's the one that gets called.
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.Paint
System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.PaintUp
System.Windows.Forms.ButtonInternal.ButtonStandardAdapter.PaintWorker
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.PaintField
System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.DrawText
In that DrawText
method, you'll see that it draws the disabled text like this:
if (disabledText3D && !Control.Enabled) {
r.Offset(1, 1);
using (SolidBrush brush = new SolidBrush(colors.highlight)) {
g.DrawString(Control.Text, Control.Font, brush, r, stringFormat);
r.Offset(-1, -1);
brush.Color = colors.buttonShadow;
g.DrawString(Control.Text, Control.Font, brush, r, stringFormat);
}
}
So, first, it draws the text, offset (1, 1)
, with colors.highlight
, and then it draws it again, but this time offset (-1, -1)
with colors.buttonShadow
. The colors
variable is a reference to a ColorData
object. If you follow the code, you'll see that the ColorData
is being created by the System.Windows.Forms.ButtonInternal.ButtonBaseAdapter.ColorOptions.Calculate
method. The colors it returns are dependent on some system settings, such normal vs. high-contrast mode. But, for a standard situation, it looks like the colors it returns are:
ColorData.highlight = SystemColors.ControlLightLight
ColorData.buttonShadow = SystemColors.ControlDark