Reputation: 71565
I have a button on a form, currently drawn using Visual Styles which on a Win7 machine is drawn using a round-ish shading gradient and a hover highlight in blue.
The word from on high is that this button, which controls whether a particular feature is on or off, should look green and highlight greener when the feature is on, and look red and highlight redder when the feature is off, without losing the overall default visual style for the button. If we simply set the BackColor we get an unshaded, untinted button that highlights around the border in the Win7 default azure.
Unfortunately this is WinForms and not WPF so I don't have advanced style control, and we're not going WPF just yet. Is there anything I can use out of the box to change the colors used by Windows Visual Styles for this one button?
EDIT: In the interest of time, I created a WPF user control with a Button, hosted in the WinForm, allowing for the advanced style and storyboard control needed. It works. I am still curious as to how this could have been done in GDI, especially as I didn't get everything I wanted with WPF either, but I have a working solution.
Upvotes: 2
Views: 1589
Reputation: 1200
If you Leave UseVisualStyleBackColor false and specify a BackColor manually with partial alpha such as "64, 255, 0, 0" the color is blended with the visual style background, and the standard theme gradient will appear tinted that color. I'm not sure if this works in Windows < 7.
Upvotes: 2