@Barbarossa:
On newer Windows' with enabled XP skin, the progressbar is automatically animated by Windows.
Values are not displayed instantly, it is an animated transition from the old value to the new value.
Try the following code to see it. The highest value is set, still it is smoothly animated:
Code: Select all
If OpenWindow(0, 0, 0, 320, 160, "ProgressBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ProgressBarGadget(0, 10, 30, 250, 30, 0, 94);,#PB_ProgressBar_Smooth)
SetGadgetState(0,94)
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
This code works correctly up to the end because there is an (empty) event loop.
Without the event loop after a state change, the progressbar display is not updated further.
That's the problem with your code. You set highest value 94, but it stops display at 88 or so,
because there is no event processing anymore. The one "While WindowEvent() : Wend" after
the state change does not help if the Windows animation is done by using a timer that fires
a few milliseconds later, after your While..Wend is already done.
You need to make sure somehow that there is always active event processing in your app.
What is the next step in your app after the last SetGadgetState with value 94?
Is there a long blocking call? If so, try to include more "While WindowEvent():Wend" there.
If possible, do long blocking work within threads. Start the worker thread and continue
event processing in the main thread, while waiting for the worker thread to finish.
To see the difference:
Blocking example, 5 seconds work:
Code: Select all
Procedure DoWork() ; blocking work
For i = 0 To 10
Delay(500)
Next i
EndProcedure
If OpenWindow(0, 0, 0, 320, 160, "ProgressBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ProgressBarGadget(0, 10, 30, 250, 30, 0, 94);,#PB_ProgressBar_Smooth)
TextGadget(1,10,65,250,30,"WORKING...")
SetGadgetState(0,94)
While WindowEvent():Wend
DoWork()
SetGadgetText(1,"DONE.")
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf
Threaded example, 5 seconds work:
Code: Select all
Procedure DoWork(t) ; non-blocking thread
For i = 0 To 10
Delay(500)
Next i
EndProcedure
If OpenWindow(0, 0, 0, 320, 160, "ProgressBarGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ProgressBarGadget(0, 10, 30, 250, 30, 0, 94);,#PB_ProgressBar_Smooth)
TextGadget(1,10,65,250,30,"WORKING...")
SetGadgetState(0,94)
While WindowEvent():Wend
work = CreateThread(@DoWork(),0)
While IsThread(work)
While WindowEvent():Wend
Wend
SetGadgetText(1,"DONE.")
Repeat : Until WaitWindowEvent()=#PB_Event_CloseWindow
EndIf