Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I make TProgressBar stop lagging?

I've got an app that runs a long set of operations, and I'm trying to use a TProgressBar to keep track of what's going on. I set a number of steps, and call .StepIt to increment the progress bar.

Problem is, it doesn't keep up very well. Instead of jumping directly to the correct position, it seems to like to slide gradually up to it. That's all well and good if it's eye candy you're after, but when I'm trying to get an accurate representation of my routine's progress, this makes it appear to be constantly lagging behind the true status. How can I turn that "feature" off?

I only notice this happening under Windows Vista. Not sure if it's also going on on XP or not, because when I test it on XP, the process goes a lot faster and it's over too quickly. :P But this may or may not be Vista-specific. Either way, it's driving me nuts. Does anyone know how to fix it?

like image 532
Mason Wheeler Avatar asked Nov 29 '22 12:11

Mason Wheeler


2 Answers

I have a quick but partial and inelegant solution, if you don't mind having the progressbar yellow instead of green:

  ProgressBar1.SmoothReverse := True;
  ProgressBar1.State := pbsPaused; // for yellow or pbsError for red

Or if you don't mind loosing the vista/theme look and go back to a flat blue one:

  UxTheme.SetWindowTheme(ProgressBar1.Handle, ' ', ' ');

The real "problem" according to Microsoft is that you try to "pervert" a ProgressBar into a Meter which they claim it is not.

You could also try to draw it yourself ;-)

like image 184
Francesca Avatar answered Dec 16 '22 12:12

Francesca


Same problem on Windows7 !!

But the answer was already in one of the older posts:

If tou make the progressbar step backwards there will NO delay !!! So I implemented this..... (and get instant updates)

if(progress < ProgressBar.Max)
then
begin
  ProgressBar.Position := progress+1;
  ProgressBar.Position := progress; //This will set Progress backwards and give an instant update....
end
else
begin //cannot set position beyond max...
  ProgressBar.Max      := progress + 1;
  ProgressBar.Position := progress + 1;
  ProgressBar.Max      := progress; //This will also set Progress backwards also so instant update........
end;
like image 31
PeeGee Avatar answered Dec 16 '22 12:12

PeeGee