views:

1895

answers:

3

I'm using a Delphi 2009 VCL TProgressBar as a kind of "empty/full" gauge.

On Vista, with Aero theme enabled, this has an animation associated with it, which is annoying and inappropriate for an gauge.

Is there any way of disabling this (NOT by adjusting user's theme settings!) to prevent the animation on this control?

Update:

I understand that I need a "meter", rather than a true progress bar. How can a themed meter be implemented using the standard windows progress bar control?

+8  A: 

As per the Vista UI guidelines for progress bars you should not be using a TProgressBar for such purposes at all, it states:

Use progress bars only for progress. Use meters to indicate percentages that aren't related to progress.

There are a lot of Third-Party components (for example Abakus VCL) that are aimed at Process Automation applications and the like, maybe you could use one of these controls instead?

mghie
Understood - but it says: "Meters: This pattern isn't a progress bar, but it is implemented using the progress bar control." How can I implement such a "Meter" using the progress bar control? As for the Abakus components, my application should look like it was designed in the last ten years or so.
Roddy
I don't know how to implement the meter, and don't have Vista here to check. Could you run Spy++ and have a look at the Windows style flags that are set for those meter controls?Spy++ comes with MS Visual C++. Google for "spy++ freeware" if you don't have it.
mghie
As for Abakus - I hear you ;-) If you need the gauge to look good in Vista it would of course be best to find a style for the common control. I just don't find anything in the Platform SDK... Check out http://msdn.microsoft.com/en-us/library/cc656530(VS.85).aspx for the available docu.
mghie
I did not find anything else regarding those "meter" controls. There is of course also the alternative of creating a TGraphicControl. Code for how to draw Vista-style progress bars using GDI+ can be found for example at http://www.codeproject.com/KB/cpp/VistaProgressBar.aspx
mghie
+1 because i think this is the correct answer. A battery does not drain or charge fast enough for the animation to be visible. A car does not burn gas, or get filled up, fast enough to make the animation important. The only example i can imagine is a CPU load, or fan speed indicator. In the end, i would think you're probably going to be forced to use a custom control (with UxTheme API drawing applied)
Ian Boyd
A: 

Have a look at this forum thread. It is the only promising link I found, and the first posting mentions the different progress bar states, so changing the properties Smooth, State and Style will probably not help.

If the the tip in the last posting is indeed the only way to draw the progress bar in meter style, then your best option is to create a descendent class of TProgressBar, override the WM_PAINT handler, check for Vista and enabled themes, and in that case use the functions in UxTheme to paint the different parts of the control.

mghie
+6  A: 

You can try turning themes off for that control;

SetWindowTheme(ProgressBar.Handle, ' ', ' ');
Tim Knipe
+1 because this answer seems useful - although i have no idea if it works, or is the correct way to intentionally disable themeing on a Common Control.
Ian Boyd
i have tested this and it works, the function is in the library UxTheme (http://msdn.microsoft.com/en-us/library/bb759827(VS.85).aspx)
Remus Rigo