Scrolling Progressbar

Just starting out? Need help? Post your questions and find answers here.
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Post by Psych »

That is chocolate !!
Exactly what I wanted !!

Thanks.
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
User avatar
Shardik
Addict
Addict
Posts: 2058
Joined: Thu Apr 21, 2005 2:38 pm
Location: Germany

Post 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
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Post 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.
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Post 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?
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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.
I may look like a mule, but I'm not a complete ass.
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Post 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.
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Post 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)
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
Psych
Enthusiast
Enthusiast
Posts: 239
Joined: Thu Dec 18, 2008 3:35 pm
Location: Wales, UK

Post by Psych »

Ok, I'm stupid, you got to OR it.

Silly me.
----------------------------------------------------------------------------
Commenting your own code is admitting you don't understand it.
----------------------------------------------------------------------------
srod
PureBasic Expert
PureBasic Expert
Posts: 10589
Joined: Wed Oct 29, 2003 4:35 pm
Location: Beyond the pale...

Post 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)
I may look like a mule, but I'm not a complete ass.
User avatar
ts-soft
Always Here
Always Here
Posts: 5756
Joined: Thu Jun 24, 2004 2:44 pm
Location: Berlin - Germany

Post by ts-soft »

Here a small example like Shardik wrote.
Works on all windows and looks better :wink:
PureBasic 5.73 | SpiderBasic 2.30 | Windows 10 Pro (x64) | Linux Mint 20.1 (x64)
Old bugs good, new bugs bad! Updates are evil: might fix old bugs and introduce no new ones.
Image
c4s
Addict
Addict
Posts: 1981
Joined: Thu Nov 01, 2007 5:37 pm
Location: Germany

Re: Scrolling Progressbar

Post 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.
If any of you native English speakers have any suggestions for the above text, please let me know (via PM). Thanks!
Post Reply