ProgressBar on StatusBar?

Just starting out? Need help? Post your questions and find answers here.
myutopia
User
User
Posts: 91
Joined: Sat Jul 04, 2009 1:29 am

ProgressBar on StatusBar?

Post by myutopia »

Hi all :)

I'm trying to get a ProgressBar to appear on the StatusBar. I can't get the bar to appear unless I move the window "off-screen" and back, or unless I hide, and unhide the window.

I think I'm doing something wrong to have to resort to such "tricks". Does someone have a better solution?

Thanks!

Code: Select all

Enumeration
   #Window
   #StatusBar
   #ProgressBar
EndEnumeration
   

If OpenWindow(#Window,#PB_Ignore,0,200,100,"Status Test")
  
  CreateStatusBar(#StatusBar, WindowID(#Window))
  AddStatusBarField(150)
  StatusBarText(#StatusBar, 0, "Howdy, mate!")
  
  ProgressBarGadget(#ProgressBar,150,79,47,20,0,100)
  SetGadgetState(#ProgressBar,50)

;   HideWindow(#Window,1) ; I need to do this to get the progress bar to show up. Am I doing something wrong?
;   HideWindow(#Window,0)
  
EndIf


Repeat
   Ev = WaitWindowEvent(1)
Until Ev = #PB_Event_CloseWindow 
eesau
Enthusiast
Enthusiast
Posts: 589
Joined: Fri Apr 27, 2007 12:38 pm
Location: Finland

Post by eesau »

Did you try using StatusbarBarProgress()? (4.40b1)
myutopia
User
User
Posts: 91
Joined: Sat Jul 04, 2009 1:29 am

Post by myutopia »

Thanks for that. Unfortunately, I can't use 4.40 yet, as there are some SQLite issues with it. I have to stick with 4.31 at the moment :(
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

Try this:

Code: Select all

If OpenWindow(0,#PB_Ignore,0,200,100,"Status Test")
  
  hstatus = CreateStatusBar(#PB_Any, WindowID(0))
  AddStatusBarField(150)
  StatusBarText(hstatus, 0, "Howdy, mate!")
  
  Hprogress = ProgressBarGadget(#PB_Any, 120, 2,100, 16, 0,100)
  
  SetGadgetState(Hprogress,50)
  
  SetParent_(GadgetID(Hprogress),StatusBarID(hstatus))
  
  Repeat
    
  Until WaitWindowEvent() = #PB_Event_CloseWindow
EndIf
myutopia
User
User
Posts: 91
Joined: Sat Jul 04, 2009 1:29 am

Post by myutopia »

Yes! That worked. Thanks, cas :)
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

Your original code seems to work fine for me on Vista ...
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

USCode wrote:Your original code seems to work fine for me on Vista ...
Works fine here on Win7, too. But... Try disabling "Enable XP skin support" in compiler options 8)
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

cas wrote:
USCode wrote:Your original code seems to work fine for me on Vista ...
Works fine here on Win7, too. But... Try disabling "Enable XP skin support" in compiler options 8)
Hmm, I wonder if this might be related to this issue:
http://www.purebasic.fr/english/viewtop ... highlight=
... which Fred just fixed for the next Beta. They both seem to be related to the XP skin support option.

We'll have to test it in the next Beta with XP skin support disabled.
cas
Enthusiast
Enthusiast
Posts: 597
Joined: Mon Nov 03, 2008 9:56 pm

Post by cas »

I don't think that this is same problem because here you have two gadgets: statusbar and progressbar but progressbar is behind statusbar - so it is hidden but when you move window outside desktop area or hide and show it then it is repainted and you can see progressbar. With XP skins it is displayed all time because of theme which is redrawing window automatically.
Solution is to set parent of progressbar so it will be always shown on top of statusbar (and not behind like in first code). :wink:
USCode
Addict
Addict
Posts: 923
Joined: Wed Mar 24, 2004 11:04 pm
Location: Seattle

Post by USCode »

cas wrote:... Solution is to set parent of progressbar so it will be always shown on top of statusbar (and not behind like in first code). :wink:
Makes sense, but then maybe we need to make an enhancement request for Fred to add a cross-platform PB function the equivalent of SetParent_ ... ?
User avatar
John Puccio
User
User
Posts: 26
Joined: Fri Jun 12, 2009 6:56 am
Location: My Keyboard

Post by John Puccio »

This works too :)

With or without skin support. But with skin support off the progress bar is a few pixels taller than the status bar. Strange..

Code: Select all

Enumeration 
  #Window 
  #StatusBar 
  #ProgressBar 
EndEnumeration 

If OpenWindow(#Window,#PB_Ignore, 0, 200, 100, "Status Test") 
  ProgressBarGadget(#ProgressBar, 150, 79, 47, 20, 0, 100) 
  SetGadgetState(#ProgressBar, 50) 

  CreateStatusBar(#StatusBar, WindowID(#Window)) 
  AddStatusBarField(150) 
  StatusBarText(#StatusBar, 0, "Howdy, mate!") 
EndIf 

Repeat 
  Ev = WaitWindowEvent(1) 
Until Ev = #PB_Event_CloseWindow 
WinXP SP3
PB4.31

JP
User avatar
Demivec
Addict
Addict
Posts: 4259
Joined: Mon Jul 25, 2005 3:51 pm
Location: Utah, USA

Post by Demivec »

John Puccio wrote:This works too :)
If you drag the window partially offscreen, then drag it back again, you can't see the ProgressBar afterwards with your code.
User avatar
John Puccio
User
User
Posts: 26
Joined: Fri Jun 12, 2009 6:56 am
Location: My Keyboard

Post by John Puccio »

Demivec wrote:If you drag the window partially offscreen, then drag it back again, you can't see the ProgressBar afterwards with your code.
Well how about that, just the opposite.. :oops: The height of the progress bar is taller than the status bar with skin support off. What exactly is going on here?

JP
Post Reply