Disabling progress bar animation on Vista Aero

2019-01-19 00:08发布

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?

5条回答
手持菜刀,她持情操
2楼-- · 2019-01-19 00:44

You can try turning themes off for that control;

SetWindowTheme(ProgressBar.Handle, ' ', ' ');
查看更多
放荡不羁爱自由
3楼-- · 2019-01-19 00:46

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?

查看更多
Animai°情兽
4楼-- · 2019-01-19 00:46

Try the VistaProBar at http://rmklever.com/ It does NOT have animation associated with it.

查看更多
We Are One
5楼-- · 2019-01-19 00:56

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...

查看更多
Animai°情兽
6楼-- · 2019-01-19 01:03

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.

查看更多
登录 后发表回答