Sign in Join

Live chat for Free Pascal, Lazarus, Delphi and every Pascal programmer.

Mailing lists / lazarus / 2018-01

Progressbar never reaches the end

5 messages · 2 people · –

Reply by email Subscribe to this list Your subscription

Read-only archive. Use j and k to move between messages.

frans

Hi.

I use Lazarus 1.6.4 on Windows10.
I use a TProgressBar in a loop to construct a report on an Dataset. The progressbar functions fine but when position=max, the progressbar visualy never reaches the end. It doesn't matter how many records there are, 100 or 10.000, the progressbar has always some white space left. I cannot believe this is normal. Using application.processmessages in the loop makes no difference.
Am I forgetting something?

mvg Frans van Leeuwen M 06-51695390 --- Deze e-mail is gecontroleerd op virussen door AVG. http://www.avg.com

Reply by email

Bart
to frans
frans wrote
The progressbar functions fine but when position=max, the progressbar visualy never reaches the end.

Thank Uncle Bill for that.
The progressbar animates to the position you set it to. This takes time.

If you do ProgressBar1.Position := ProgressBar1.Max and the
(physically) wait a while, it will get to full 100%.

The trick to get an immediate update is to decrement the position: no animation, no waiting time.
Unfortunately this cannot be done for the 100% value.

I have some code in one of my apps like this to get rid of the animation:

  {$ifdef windows}
  if Value > 0 then
  begin
    //trick modern Windows to draw the position at once, otherwise you
never see the 100%
    ProgressBar.Position := Value - 1;
    ProgressBar.Repaint;
    ProgressBar.Position := Value;
    ProgressBar.Repaint;
  end;
  {$endif}

If it bothers you, there are plenty of customdrawn progressbars out there (or switch of themes, to get the old behaviour back).

Bart

Reply by email

frans
to Bart

Thx Bart for the reply.
But where stands Value for?
I tried a recordcounter, but that was even worse.

mvg
Frans van Leeuwen
M 06-51695390

Op 25-1-2018 om 19:36 schreef Bart via Lazarus:

Show quoted text 35 lines
On Thu, Jan 25, 2018 at 7:27 PM, frans via Lazarus wrote: > The > progressbar functions fine but when position=max, the progressbar visualy > never reaches the end. Thank Uncle Bill for that. The progressbar animates to the position you set it to. This takes time. If you do ProgressBar1.Position := ProgressBar1.Max and the (physically) wait a while, it will get to full 100%. The trick to get an immediate update is to decrement the position: no animation, no waiting time. Unfortunately this cannot be done for the 100% value. I have some code in one of my apps like this to get rid of the animation: {$ifdef windows} if Value > 0 then begin //trick modern Windows to draw the position at once, otherwise you never see the 100% ProgressBar.Position := Value - 1; ProgressBar.Repaint; ProgressBar.Position := Value; ProgressBar.Repaint; end; {$endif} If it bothers you, there are plenty of customdrawn progressbars out there (or switch of themes, to get the old behaviour back). Bart

---
Deze e-mail is gecontroleerd op virussen door AVG. http://www.avg.com

Reply by email

frans
to Bart: On Thu, Jan 25, 2018 at 7:27 PM, frans via Lazarus Thank Uncle Bill for that. The…

Hi Bart.
Forget my previous mail, I placed the Increment command in teh wrong loop. Now, in the right loop, it makes a small better difference. Thx.

mvg
Frans van Leeuwen
M 06-51695390

Op 25-1-2018 om 19:36 schreef Bart via Lazarus:

Show quoted text 35 lines
On Thu, Jan 25, 2018 at 7:27 PM, frans via Lazarus wrote: > The > progressbar functions fine but when position=max, the progressbar visualy > never reaches the end. Thank Uncle Bill for that. The progressbar animates to the position you set it to. This takes time. If you do ProgressBar1.Position := ProgressBar1.Max and the (physically) wait a while, it will get to full 100%. The trick to get an immediate update is to decrement the position: no animation, no waiting time. Unfortunately this cannot be done for the 100% value. I have some code in one of my apps like this to get rid of the animation: {$ifdef windows} if Value > 0 then begin //trick modern Windows to draw the position at once, otherwise you never see the 100% ProgressBar.Position := Value - 1; ProgressBar.Repaint; ProgressBar.Position := Value; ProgressBar.Repaint; end; {$endif} If it bothers you, there are plenty of customdrawn progressbars out there (or switch of themes, to get the old behaviour back). Bart

---
Deze e-mail is gecontroleerd op virussen door AVG. http://www.avg.com

Reply by email