Page 1 of 2
"waiting" type progress bar...
Posted: Wed Apr 12, 2023 4:02 am
by jassing
I tried using a scrollbar, but
A) I can't change its colour
B) Arrows can't be removed
C) there's an artifact around it.
Any ideas for alternatives? I have a process that waits on a remote server to respond, so the time to wait is unknown, I need to let the user know it's working, and provide ability to cancel waiting...
Code: Select all
OpenWindow(0, x, y, 460, 50, "test")
ScrollBarGadget(1, 10, 10, 440, 25, 0, 100, 0)
For a = 1 To 5
For x = 1 To 100
SetGadgetState(1,x)
WaitWindowEvent(10)
Next
For x = 99 To 2 Step -1
SetGadgetState(1,x)
WaitWindowEvent(10)
Next
Next
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 6:53 am
by Bisonte
in memory of the good old DOS times
Code: Select all
Global Dim Anim.s(4)
Anim(1) = "Please wait. |"
Anim(2) = "Please wait. /"
Anim(3) = "Please wait. -"
Anim(4) = "Please wait. \"
OpenWindow(0, x, y, 460, 50, "test")
AddWindowTimer(0, 123,250)
ButtonGadget(1, 400, 10, 55, 30, "Cancel")
TextGadget(2, 20, 10, 80, 30, "", #SS_CENTERIMAGE)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Break
EndSelect
Case #PB_Event_Timer
Select EventTimer()
Case 123
State + 1
If State >= 5
State = 1
EndIf
SetGadgetText(2, Anim(State))
EndSelect
EndSelect
ForEver
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 8:51 am
by BarryG
Third option (for Windows only): the animated ProgressBarGadget():
Code: Select all
OpenWindow(0, 300, 200, 460, 50, "test")
ButtonGadget(1, 400, 10, 55, 30, "Cancel")
ProgressBarGadget(2, 10, 10, 380, 30, 1, 2)
SetGadgetState(2,-1) ; -1 = Animated progress.
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_CloseWindow
Break
Case #PB_Event_Gadget
Select EventGadget()
Case 1
Break
EndSelect
EndSelect
ForEver
Fourth option: an animated GIF on the window of your choice (like a rotating hourglass, etc).
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 10:12 am
by Shardik
In PB 5.40 the new Flag
#PB_ProgressBar_Unknown has been added to the
ProgressBarGadget. And so it has become very easy to display a "waiting type" progress bar cross-platform:
Code: Select all
OpenWindow(0, 270, 100, 270, 70, "Wait animation")
ProgressBarGadget(0, 10, 20, 250, 30, 0, 10)
SetGadgetState(0, #PB_ProgressBar_Unknown)
Repeat
Until WaitWindowEvent() = #PB_Event_CloseWindow
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 10:48 am
by BarryG
Beat ya to it, Shardik! Hehe. But I didn't know it was cross-platform now with a #PB_ProgressBar_Unknown flag, so thanks for the tip!
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 1:51 pm
by jassing
Bisonte wrote: Wed Apr 12, 2023 6:53 am
in memory of the good old DOS times

HA! Awesome!! I used to use that !! I completely forgot about something simple like that -- that's a good option. I had "cylon" or "nightrider's kitt" car in my head for some reason. (I thought about using an animated gif, like
https://dribbble.com/shots/2827635-Cylon-Animation)
Thanks for the trip back to the 80's!!!
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 1:54 pm
by jassing
BarryG wrote: Wed Apr 12, 2023 8:51 am
Third option (for Windows only): the animated ProgressBarGadget():
I didn't know it could that, if only it could go 'backwards' too....
Thanks to you both for that idea. I like it, especially since it's dirt simple; if I could only 'stop' it. ( I need to pause it if something hangs during the process)
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 2:45 pm
by RASHAD
Hi
Code: Select all
If OpenWindow(0,0,0,220,100,"Busy..",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
ProgressBarGadget(0,10,10,200,16,0,100,10|#WS_BORDER)
SetWindowTheme_(GadgetID(0), "", "")
SetGadgetColor(0,#PB_Gadget_BackColor ,$E4E4E4)
SetGadgetColor(0,#PB_Gadget_FrontColor ,$21A1FE)
SendMessage_(GadgetID(0),1034,1,0)
SetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE) | #WS_EX_LAYOUTRTL)
Repeat
Select WaitWindowEvent()
Case #PB_Event_CloseWindow
Quit = 1
EndSelect
Until Quit = 1
EndIf
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 2:59 pm
by jassing
RASHAD wrote: Wed Apr 12, 2023 2:45 pm
Code: Select all
ProgressBarGadget(0,10,10,200,16,0,100,10|#WS_BORDER)
SetWindowTheme_(GadgetID(0), "", "")
SetGadgetColor(0,#PB_Gadget_BackColor ,$E4E4E4)
SetGadgetColor(0,#PB_Gadget_FrontColor ,$21A1FE)
SendMessage_(GadgetID(0),1034,1,0)
SetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE) | #WS_EX_LAYOUTRTL)
Neat. Is there a way to pause it?
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 4:16 pm
by RASHAD
Hand Made ProgressBar
Code: Select all
Global x
Procedure scrollText(param, timer)
x - 1
If x = -380
x = 380
EndIf
MoveWindow_(GadgetID(1),x,0,376,20,1)
EndProcedure
OpenWindow(0, 0, 0, 400, 130, "Hand Made ProgressBar", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
SmartWindowRefresh(0,1)
ContainerGadget(0,10,10,380,20,#PB_Container_Flat)
SetGadgetColor(0,#PB_Gadget_BackColor,$CFFEE7)
ImageGadget(1,180,0,380,20,0)
CloseGadgetList()
CreateImage(0,130,20,24,$CFFEE7)
StartDrawing(ImageOutput(0))
Box(0,0, 40,20,$22A7FE)
Box(70,0, 40,20,$22A7FE)
StopDrawing()
DisableGadget(0,1)
SetGadgetState(1,ImageID(0))
ButtonGadget(2,10,98,40,24,"ON",#PB_Button_Toggle)
x = 180
cycle = 5
Repeat
Select WindowEvent()
Case #PB_Event_CloseWindow
timeKillEvent_(TEvent)
Quit = 1
Case #PB_Event_Gadget
Select EventGadget()
Case 2
If GetGadgetState(2) = 1
SetGadgetText(2,"OFF")
TEvent = timeSetEvent_(cycle,0,@ScrollText(),0,#TIME_PERIODIC)
Else
SetGadgetText(2,"ON")
timeKillEvent_(TEvent)
ResizeGadget(1,x,#PB_Ignore,#PB_Ignore,#PB_Ignore)
EndIf
EndSelect
EndSelect
Until Quit = 1
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 4:20 pm
by jassing
RASHAD wrote: Wed Apr 12, 2023 4:16 pm
Hand Made ProgressBar
You never cease to impress me. Thanks!! Very nice!
Re: "waiting" type progress bar...
Posted: Wed Apr 12, 2023 5:47 pm
by Caronte3D
RASHAD wrote: Wed Apr 12, 2023 2:45 pm
SendMessage_(GadgetID(0),1034,1,0)
SetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE, GetWindowLongPtr_(GadgetID(0), #GWL_EXSTYLE) | #WS_EX_LAYOUTRTL)
Where hell you find that things??

Re: "waiting" type progress bar...
Posted: Sun Apr 16, 2023 9:46 pm
by RichAlgeni
RASHAD wrote: Wed Apr 12, 2023 2:45 pm
Where hell you find that things??
Brilliance happens.
Re: "waiting" type progress bar...
Posted: Mon Apr 17, 2023 4:17 pm
by ebs
RASHAD wrote: Wed Apr 12, 2023 2:45 pm
Code: Select all
SendMessage_(GadgetID(0),1034,1,0)
PLEASE tell me what Windows message 1034 is!
I looked at all the messages that have that value and I can't see anything that relates to a progress bar.
Re: "waiting" type progress bar...
Posted: Mon Apr 17, 2023 4:20 pm
by Fred
RASHAD hidden magic, don't try to understand it. Just accept.