views:

427

answers:

1

The WinForms ProgressBar control allows its foreground color to be set. While this normally works fine, the foreground color setting seems to be ignored on XP when using the obnoxious Luna style: it is always green.

Similaraly, XP Luna seems to ignore the 'Style': Although I have set it to 'Continuous', the progress bar is always drawn with blocks.

Is this supposed to be correct behavior? Is there a way to work around this?

Thanks.

A: 

To disable the Luna visual style, you can remove the call to Application.EnableVisualStyles() in the auto-generated Program class.

This will make all controls on forms created after that point to look like Windows 2000.

You can conditionally call it depending on the OS, since Vista's visual styles respect the Style property, IIRC (can't test right now - my laptop died).


You can handle the rendering of the control manually via the Paint event or by deriving from the control and overriding OnPaint*().

You could also roll your own from scratch, since progress bars are rather simple.

pyrochild
Hm. Unfortunately, the form is hosted by a VisualStudio AddIn -- so I cannot disable the Luna visual style alltogether.
Well that certainly changes things ;)
pyrochild
Well, I hoped there was an easier solution than that... but it seems that this really is a breaking API change (which I consider a bug). Thanks though.
Maybe you can make the add-in an interop layer, with the actual Form being hosted out-of-process? There are probably open-source progress bar controls available as well.
pyrochild