View Issue Details

IDProjectCategoryView StatusLast Update
0036471LazarusLCLpublic2019-12-22 21:28
ReporterPantey Assigned ToBart Broersma  
PrioritynormalSeverityminorReproducibilityalways
Status resolvedResolutionno change required 
Platformwin32OSWindows 
Product Version2.0.6 
Summary0036471: TProgressBar always shows wrong progress at increasing position, but shows correctly at decreasing position.
DescriptionTProgressBar always shows wrong progress at increasing position, but shows correctly at decreasing position.
This is not very noticeable with a large number of small increments, but it is clearly visible with several large increments.

There is an attached simplified example (with no any other tasks) demonstrating a problem.
A StaticText.Caption shows a value from ProgressBar.Position, but ProgressBar shows bar at the previous position.
The proportions of the increment of steps are violated, but the final value of 100% is achieved by a large jump.
TagsNo tags attached.
Fixed in Revision
LazTarget-
WidgetsetWin32/Win64
Attached Files

Activities

Pantey

2019-12-22 13:42

reporter  

PB-Problem.zip (952,507 bytes)

Bart Broersma

2019-12-22 16:47

developer   ~0120022

Windows animates the progression of the increase of Position.
Your Sleep(2000) prevents showing this animation taking place at the time you expect it.
Only on the next iteration the progressbar will go to the position that it was set to in the previous iteration.

Because animation does NOT take place if you decrease Position, you get the immediate result you want.

If you do the following, you will see that it works as "expected" (it's a really annoying feature of Windows and you can't seem to turn that off).

In the Buttons OnClick simply increase Position by 25 (no loop, no ApplicationProcessMessages).
Click the button 4 times (not to fast) and see how the progressbar "grows" to the expected position.

Workaround 1:
Set Positions to DesiredValue + 1, then Position to DesiredValue,
Does of course not work if DesireValue equals Max

Workaround 2:
Use a custom ProgressBar. There are plenty of them out there.

Bart Broersma

2019-12-22 16:47

developer   ~0120023

Please close this issue.

Pantey

2019-12-22 17:19

reporter   ~0120024

Thank you for quick answer!
Sleep(2000) in my example works instead of my own intensive task with file system, which has absolutely the same behavior like Sleep(2000).
If there is nothing to do due to Windows behavior then it is sadly. In this case only two ways:
1) to incapsulate my task into some thread (which is not so easy),
2) to use something else instead of ProgressBar.

CudaText man

2019-12-22 21:28

reporter   ~0120028

Try ATGauge in ATFlatControl package.
https://github.com/Alexey-T/ATFlatControls

Issue History

Date Modified Username Field Change
2019-12-22 13:42 Pantey New Issue
2019-12-22 13:42 Pantey File Added: PB-Problem.zip
2019-12-22 16:47 Bart Broersma Note Added: 0120022
2019-12-22 16:47 Bart Broersma Assigned To => Bart Broersma
2019-12-22 16:47 Bart Broersma Status new => resolved
2019-12-22 16:47 Bart Broersma Resolution open => no change required
2019-12-22 16:47 Bart Broersma LazTarget => -
2019-12-22 16:47 Bart Broersma Widgetset Win32/Win64 => Win32/Win64
2019-12-22 16:47 Bart Broersma Note Added: 0120023
2019-12-22 17:19 Pantey Note Added: 0120024
2019-12-22 21:28 CudaText man Note Added: 0120028