14

Possible Duplicate:
Windows 7 Aero Theme Progress Bar Bug?

Ever since Windows Vista, I have noticed a bug/problem with the TProgressBar in Delphi.

The problem is the progressbar never seems to fill up to 100%, sometimes it gets to maybe 70% - 80% before the progressbar thinks its hit the max, i.e 100%

I have been reading on various websites and infact, the progressbar has complete its operation. But it seems that there is a bug in the Delphi VCL which is not rendering the progressbar accurately, so when it appears to be complete but is actually not, this is because the painting of the progressbar is not accurate.

If the above is true, which seems a valid reason - I have not found a solution to this. Whatever the operation which involves a TProgressBar, it never fills up 100%, it only fill maybe 75% of the way.

How can I get the TProgressBar to fill up accurately?

To add, I have tried replacing the TProgressBar with say a progressbar from the JVCL and those non standard VCL components work correctly. So it is not a problem with how I am dealing with the progress, it is either Delphi or Windows - or both.

Yes, I could just use said alternative but if possible I would like to know how to fix the standard TProgressBar.

Thanks, Craig.

Community
  • 1
  • 1
  • 1
    Which version of Delphi are you using? Try creating a new project, adding a progress bar and then manually setting the [Position](http://docwiki.embarcadero.com/VCL/en/ComCtrls.TProgressBar.Position) to 100. – stukelly May 25 '11 at 17:18
  • 2
    I like the progressbars that get to 100 and go back to 0 a random number of times :) – bwawok May 25 '11 at 17:22
  • 4
    The Delphi VCL is not the one who renders the progress bar. The progress bar is a Windows common control; the OS is responsible for painting it. – Rob Kennedy May 25 '11 at 18:28
  • This is a really oddball element of windows vista themes. – Warren P May 25 '11 at 19:09
  • See for more info about this problem: http://stackoverflow.com/questions/2217688/windows-7-aero-theme-progress-bar-bug – onnodb May 26 '11 at 08:44

1 Answers1

25

This is a feature of Vista themes. The only known way to work around this feature is to go backwards during an update.

Every time you set the progress bar counter to N immediately afterwards set it to N-1.

There's nothing wrong with the Delphi code, it's a feature of the common control.

David Heffernan
  • 601,492
  • 42
  • 1,072
  • 1,490
  • 4
    You really ought to put "feature" in quotes in your answer, since it's not what most users would recognize as one. – Mason Wheeler May 25 '11 at 18:04
  • 2
    @mason I suppose it's more a consequence of the feature that vista progress bars are smoother than xp. – David Heffernan May 25 '11 at 18:08
  • 6
    Yeah, but when you throw out accuracy and correctness in favor of "looking smooth," on a control whose entire purpose for existing is to provide an accurate readout of progress, that's not a feature. – Mason Wheeler May 25 '11 at 18:48
  • 4
    @Mason I'm not defending it! It is what it is, and this is the way to defeat it. – David Heffernan May 25 '11 at 18:53
  • 4
    Is it accurate to say "it's an animation feature which you might feel animates too slowly".... – Warren P May 25 '11 at 19:08
  • 1
    Another way of looking at this is that a progress bar is a meter which measures progress, just as a speedometer measures speed or a thermometer measure temperature. These meters are useful because they display the speed, temperature or progress **now**, not some time back. The traffic police would not accept the excuse that you were driving too fast because your speedometer only shows a delayed reading. Let's be straight - this "feature" is just an OS bug introduced because M$ were trying to be cleverer than they actually are. Nice workaround though! – Reversed Engineer Jul 10 '17 at 10:34
  • Hi. First, I also don't agree this is a feature. It is an "annoying" feature in the BEST case, or a bug. Second, I guess Delphi (VCL) could implement the fix on its own. We do agree that VCL is better than the standard MS API; right? :) – Gabriel Mar 29 '22 at 08:27
  • @ServerOverflow It's as designed and that makes it a feature. They intentionally changed it to behave like this. I don't dispute that you are annoyed by it. The VCL is just a wrapper around Win32. – David Heffernan Mar 29 '22 at 08:49