In a custom control, deriving from Button, the ButtonRenderer.DrawButton() draws a button, in various states.
All is fine when the display settings in Windows are set to a color-depth of 32-bits, but once, it is set to 16-bits, the color does not match one of a regular WinForms button and it stands out in my UI, which I do not really want.
I've replicated this using a minimal example code like this.
protected override void OnPaint(PaintEventArgs e)
{
base.OnPaint(e);
Rectangle rect = new Rectangle(10, 10, 250, 120);
ButtonRenderer.DrawButton(e.Graphics, rect, PushButtonState.Normal);
rect = new Rectangle(300, 300, 250, 120);
ControlPaint.DrawButton(e.Graphics, rect, ButtonState.Normal);
}
which gives this...
I'm sure you will all notice that the two "buttons" drawn by the DrawButton methods have a slightly lighter color than the standard button, and Form background (which I didn't change and left as the default which is "Control")... If you zoom enough, you can see that it is alternating pixels of the correct background color and another brighter color...
I spotted this issue because our users are using Remote Desktop (RDP) to connect to our applications. Forcing the remote desktop settings to 32-bits resolves the problem but I think it has a performance impact, and some of our users are working overseas over relatively slow broadband links... so enforcing 32-bits is an option I would prefer to avoid. It also happens in front of a PC, by setting the display settings to 16-bits colors.
Do you please have any ideas? Is it some kind of bug with ButtonRenderer and ControlPaint classes, or is there a way around this? (I'm using .Net 4.0).