AlainD
AlainD

Reputation: 6587

Change visual step size of TProgressBar?

I have a form with a TProgressBar set up as follows:

myProgressBar.Step := 1;
myProgressBar.Min := 0;
myProgressBar.Max := 60;
myProgressBar.Position := 0;

A timer with 1000ms interval is started on form start and every timer tick the progress bar is stepped. After 60s the bar is nearly full (see image, with a debug label showing the time elapsed) but there are only ~19.5 blocks in the bar, not my expected 60. This means that you only see a step about every 3s.

TProgressBar with overly chunky steps

Is there anything I can do about this? None of the exposed properties in the designer seem to help. I'd be happy to send the control a message if this solved the problem. For example, I use this code elsewhere to change the colour of a progress bar at runtime:

SendMessage(pbBin1.Handle, PBM_SETBARCOLOR, 0, clLime);

Upvotes: 3

Views: 562

Answers (1)

David Heffernan
David Heffernan

Reputation: 612794

The progress bar is drawn by the system and you don't get to choose the block size. Instead you could use a smooth progress bar. Set the Smooth property to True.

Upvotes: 5

Related Questions