Page 1 of 1
ProgressBar on StatusBar?
Posted: Mon Aug 17, 2009 12:41 pm
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
Posted: Mon Aug 17, 2009 12:55 pm
by eesau
Did you try using StatusbarBarProgress()? (4.40b1)
Posted: Mon Aug 17, 2009 12:59 pm
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

Posted: Mon Aug 17, 2009 1:27 pm
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
Posted: Mon Aug 17, 2009 2:00 pm
by myutopia
Yes! That worked. Thanks, cas

Posted: Mon Aug 17, 2009 6:45 pm
by USCode
Your original code seems to work fine for me on Vista ...
Posted: Mon Aug 17, 2009 6:51 pm
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

Posted: Mon Aug 17, 2009 6:58 pm
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

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.
Posted: Mon Aug 17, 2009 7:05 pm
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).

Posted: Mon Aug 17, 2009 7:57 pm
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).

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_ ... ?
Posted: Tue Aug 18, 2009 2:28 am
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
Posted: Tue Aug 18, 2009 2:32 am
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.
Posted: Tue Aug 18, 2009 3:02 am
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..

The height of the progress bar is taller than the status bar with skin support off. What exactly is going on here?
JP