问题
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?
To clarify, I want something basically identical to the 'disk space used' meters in Windows Explorer. No animation, but still with a nice border and shading effects.
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?
回答1:
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?
回答2:
You can try turning themes off for that control;
SetWindowTheme(ProgressBar.Handle, ' ', ' ');
回答3:
Try the VistaProBar at http://rmklever.com/ It does NOT have animation associated with it.
回答4:
I haven't tried it yet, but this question looks to have a useful answer for winforms.
How can I use a meter-style progress bar?
Now to convert it to Delphi...
回答5:
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.
来源:https://stackoverflow.com/questions/313792/disabling-progress-bar-animation-on-vista-aero