Page 1 of 1
Scrolling Progressbar
Posted: Mon May 04, 2009 1:08 pm
by Psych
Can we have a progressbar that just scrolls (indicating it's busy), I'm sure you've seen this, a few blocks that flow across the bar, values make no difference.
Any ideas?
Posted: Mon May 04, 2009 1:24 pm
by srod
Why not shove a progressbar gadget inside some kind of timer or thread?
Posted: Mon May 04, 2009 1:29 pm
by Psych
I can have the progress changing but that fills the progressbar, that isn't the effect I am looking for, what I'd like is to have maybe 2 or 3 bars scroll from left to right continuously.
I think the style is called marquee, or something like that.
Posted: Mon May 04, 2009 1:35 pm
by srod
Code by Sparkie :
Code: Select all
; --> *** Requires WinXP with XP skins enabled ***
#PBS_MARQUEE = 8
#PBM_SETMARQUEE = #WM_USER + 10
If OpenWindow(0, 0, 0, 320, 160, "", #PB_Window_SystemMenu | #PB_Window_ScreenCentered)
ProgressBarGadget(0, 10, 30, 300, 20, 0, 100, #PBS_MARQUEE)
ButtonGadget(1, 110, 70, 75, 20, "On")
HideGadget(0, 1)
Repeat
Event = WaitWindowEvent()
Select Event
Case #PB_Event_Gadget
Select EventGadget()
Case 1
If GetGadgetText(1) = "On"
SetGadgetText(1, "Off")
HideGadget(0, 0)
SendMessage_(GadgetID(0), #PBM_SETMARQUEE, 1, 100) ; on
Else
SetGadgetText(1, "On")
SendMessage_(GadgetID(0), #PBM_SETMARQUEE, 0, 0) ; off
HideGadget(0, 1)
EndIf
EndSelect
EndSelect
Until Event = #PB_Event_CloseWindow
EndIf
Alter the value 100 to alter the animation speed etc.
Posted: Mon May 04, 2009 1:48 pm
by Psych
That is chocolate !!
Exactly what I wanted !!
Thanks.
Posted: Tue May 05, 2009 8:36 am
by Shardik
Another approach would be to display the progress bar as an animated GIF image. In the German forum in a similar thread (
http://www.purebasic.fr/german/viewtopic.php?t=19786) the following links were posted which allow you to interactively design your own customized download indicator in different graphical shapes and colors. If you are satisfied with your result you are allowed to download the animation as a GIF file:
http://www.ajaxload.info
http://preloaders.net
To display the animated GIF image you can utilize the web gadget as PB already demonstrated in a rather old posting (which has to be adapted to PB 4):
http://www.purebasic.fr/english/viewtopic.php?t=3817
Posted: Tue May 05, 2009 9:48 am
by Psych
Thanks again, I think the send message approach does exactly what I need, it's a windows only app anyway. I think it looks a little nicer than simply displaying a wait message.
Posted: Sat May 09, 2009 11:11 am
by Psych
A small thing, when you stop it, that's all it does, stop... It doesnt go back to it's original behaviour.
Any way to get it to report progress again?
Posted: Sat May 09, 2009 11:26 am
by srod
Not sure what you are after but
Code: Select all
SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) & ~#PBS_MARQUEE)
will remove the marquee style and you can then use SetGadgetState() etc. to set the progress position.
Posted: Sat May 09, 2009 11:30 am
by Psych
I was actually just reading about that on MSDN.
We are very fortunate to have a community of people that know this stuff, would of taken me ages to figure out what to put in there.
Thanks srod.
Posted: Sat May 09, 2009 11:38 am
by Psych
I modified the code example to take the style off, and that works like a charm, should removing the tilde (~) not set it back on again?
Code: Select all
SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) & #PBS_MARQUEE)
Posted: Sat May 09, 2009 11:41 am
by Psych
Ok, I'm stupid, you got to OR it.
Silly me.
Posted: Sat May 09, 2009 11:53 am
by srod
If you want to toggle the style then use Xor :
Code: Select all
SetWindowLong_(GadgetID(0), #GWL_STYLE, GetWindowLong_(GadgetID(0), #GWL_STYLE) ! #PBS_MARQUEE)
Posted: Sat May 09, 2009 10:54 pm
by ts-soft
Here a small example like Shardik wrote.
Works on all windows and looks better

Re: Scrolling Progressbar
Posted: Tue Feb 09, 2010 11:58 pm
by c4s
I don't get it... Why does the code from Sparkie posted srod not work here? Nothing moves.
Also this SetWindowLongPtr_() thing doesn't work here.
P.S.
Skin support is activated. Using XP SP3.