I was testing bunch of custom controls using Managed paint API on Windows Vista. Basically, managed and unmanaged paint API use native resources of the OS to paint controls, so if you run your controls on Windows XP you’ll get XP look and feel and if you run it on Vista, you get new vistaish look and feel, right? All control parts I’ve tested seems to work, but there is a catch! If you draw a disabled TextBox, it looks strange in Windows Vista, but looks right in XP:

1
2
VisualStyleRenderer renderer = new VisualStyleRenderer(VisualStyleElement.Button.PushButton.Disabled);
renderer.DrawBackground(e.Graphics, ClientRectangle);

While this code looks fine in XP, it produces a flat blue textbox on Vista.

As far as I could tell, this is an issue with textbox only and other controls like buttons, etc render correctly in both OSes.

I wonder why?! From end-user’s perspective this does not look like disabled piece of UI and even worse it doesn’t look like a native disabled texbox on Vista. I still don’t know about any workarounds and I doubt it if native calls to UxTheme API would solve this.