Just another Progressbar
- Hroudtwolf
- Addict
- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
- Contact:
Just another Progressbar
Code updated for 5.20+, see the last post of this page.
Ladys and Gentleman,
...a wonder....a new star on the PB-sky...
The........Percent-BAr...
This ist a Gadget like the original ProgressbarGadget. But there is a percentdisplay in the bar.
I wish ya a lot of fun with it....
[edited]Code wasn't up to date.[/edited]
Ladys and Gentleman,
...a wonder....a new star on the PB-sky...
The........Percent-BAr...
This ist a Gadget like the original ProgressbarGadget. But there is a percentdisplay in the bar.
I wish ya a lot of fun with it....
[edited]Code wasn't up to date.[/edited]
Last edited by Hroudtwolf on Wed Feb 25, 2009 1:15 am, edited 2 times in total.
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
Re: Just another Progressbar
Very nice..
- np
- np
- Hroudtwolf
- Addict
- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
- Contact:
- NoahPhense
- Addict
- Posts: 1999
- Joined: Thu Oct 16, 2003 8:30 pm
- Location: North Florida
- Hroudtwolf
- Addict
- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
- Contact:
You wish. I obey
ColorButton:
ButtonIconGadget:
Do you want more ?

ColorButton:
Code: Select all
Procedure ColorButton(gadget,text.s,x,y,w,h,color.l,imageID)
if createimage (imageID,w,h)
if Startdrawing (imageoutput())
box(0,0,w,h,color.l)
locate (2,2)
if text.s<>"":drawtext (text.s):endif
Stopdrawing()
endif
endif
ButtonImageGadget (gadget,x,y,w,h,useimage (imageID))
EndProcedure
ButtonIconGadget:
Code: Select all
Procedure ButtonIconGadget (gadget.l,x.l,y.l,width.l,height.l,text.s,image.l,bcol.l,fcol.l)
If CreateImage (100+gadget.l,width.l,height.l)
If StartDrawing (ImageOutput ())
DrawingMode(0)
Box (0,0,width.l,height.l,bcol.l)
DrawImage (image.l,2,2,height.l-4,height.l-4)
DrawingMode (1)
rt.l=Red(fcol.l)
gr.l=Green(fcol.l)
bl.l=Blue(fcol.l)
FrontColor (rt.l,gr.l,bl.l)
Locate (height.l,7)
If text.s<>"":DrawText (text.s):EndIf
StopDrawing ()
EndIf
EndIf
ButtonImageGadget (1,x.l,y.l,width.l,height.l,UseImage (100+gadget))
EndProcedure
Do you want more ?
- Hroudtwolf
- Addict
- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
- Contact:
- Psychophanta
- Always Here
- Posts: 5153
- Joined: Wed Jun 11, 2003 9:33 pm
- Location: Anare
- Contact:
Re: Just another Progressbar
Useful stuff
By the way:

By the way:
Where are the ladies ?Hroudtwolf wrote:Ladys and Gentleman,

- Hroudtwolf
- Addict
- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
- Contact:
if you meet a 'gril' make sure you got the 'stakes' ready... 

( PB6.00 LTS Win11 x64 Asrock AB350 Pro4 Ryzen 5 3600 32GB GTX1060 6GB)
( The path to enlightenment and the PureBasic Survival Guide right here... )
( The path to enlightenment and the PureBasic Survival Guide right here... )
- Hroudtwolf
- Addict
- Posts: 803
- Joined: Sat Feb 12, 2005 3:35 am
- Location: Germany(Hessen)
- Contact:
Code updated for 5.20+
I couldn't find a library for PB v4, so I made this one.
I couldn't find a library for PB v4, so I made this one.

Code: Select all
; PercentBarGadget
;
; Author: breeze4me
; Date: 1st May, 2006
;
; For PureBasic v4.00 Beta 11
;
Structure PercentBar
;hPercentBar.l
img.i
Width.l
Height.l
Min.l
Max.l
Value.i
TextColor.l
FrontColor.l
BackColor.l
TextX.l
TextY.l
TextFont.i
EndStructure
Declare SetPercentBarValue(GadgetNumber, Value)
Procedure SetPercentBarColor(GadgetNumber, FrontColor, BackColor, TextColor=$FFFFFF)
Protected *mem, *prop.PercentBar
If IsGadget(GadgetNumber)
*mem = GetWindowLong_(GadgetID(GadgetNumber), #GWL_USERDATA)
*prop = *mem
*prop\TextColor = TextColor
If FrontColor<>#PB_Default : *prop\FrontColor = FrontColor : EndIf
If BackColor<>#PB_Default : *prop\BackColor = BackColor : EndIf
EndIf
EndProcedure
Procedure PercentBarGadget(GadgetNumber, x, y, Width, Height, Min, Max)
Protected *mem, *prop.PercentBar
Protected hPercentBar, img=CreateImage(#PB_Any, Width, Height)
Protected SysCol1, SysCol2
If Min>=Max : ProcedureReturn 0 : EndIf
If img
hPercentBar = ImageGadget(GadgetNumber, x, y, Width, Heigth, 0)
If hPercentBar
*mem = AllocateMemory(SizeOf(PercentBar))
SetWindowLong_(hPercentBar, #GWL_USERDATA, *mem)
*prop = *mem
;*prop\hPercentBar= hPercentBar
*prop\img = img
*prop\Max = Max
*prop\Min = Min
*prop\Width = Width
*prop\Height = Height
SysCol1 = GetSysColor_(#COLOR_3DHIGHLIGHT)
SysCol2 = GetSysColor_(#COLOR_3DSHADOW)
SetPercentBarColor(GadgetNumber,GetSysColor_(#COLOR_HIGHLIGHT),GetSysColor_(#COLOR_BTNFACE), GetSysColor_(#COLOR_CAPTIONTEXT))
If StartDrawing(ImageOutput(img))
*prop\TextX = (Width-1-TextWidth("100 %"))/2
*prop\TextY = (Height-TextHeight(" "))/2 ;+ 1
Box(0, 0, Width, Height, *prop\BackColor)
Line(0, 0, 0, Height, SysCol2)
Line(0, 0, Width, 0, SysCol2)
Line(0, Height-1, Width, 0, SysCol1)
Line(Width-1, 0, 0, Height, SysCol1)
StopDrawing()
EndIf
SetPercentBarValue(GadgetNumber, Min)
ProcedureReturn hPercentBar
EndIf
EndIf
EndProcedure
Procedure SetPercentBarValue(GadgetNumber, Value)
Protected *mem, *prop.PercentBar, ValueF.f
If IsGadget(GadgetNumber)
*mem = GetWindowLong_(GadgetID(GadgetNumber), #GWL_USERDATA)
*prop = *mem
If Value>*prop\Max : Value=*prop\Max : EndIf
If Value<*prop\Min : Value=*prop\Min : EndIf
*prop\Value = Value
ValueF = (Value-*prop\Min) * 100.0 / (*prop\Max-*prop\Min)
If StartDrawing(ImageOutput(*prop\img))
Box(1, 1, *prop\Width-2, *prop\Height-2, *prop\BackColor)
Box(1, 1, (*prop\Width-2) * ValueF / 100.0, *prop\Height-2 , *prop\FrontColor)
DrawingMode(#PB_2DDrawing_Transparent)
If *prop\TextFont : DrawingFont(*prop\TextFont) : EndIf
DrawText(*prop\TextX, *prop\TextY, Str(Int(ValueF))+" %", *prop\TextColor)
StopDrawing()
SetGadgetState(GadgetNumber, ImageID(*prop\img))
EndIf
EndIf
EndProcedure
Procedure SetPercentBarFont(GadgetNumber, FontName$, YSize, Flag=0)
Protected *mem, *prop.PercentBar
If IsGadget(GadgetNumber)
*mem = GetWindowLong_(GadgetID(GadgetNumber), #GWL_USERDATA)
*prop = *mem
*prop\TextFont = FontID(LoadFont(#PB_Any, FontName$, YSize, Flag))
If StartDrawing(ImageOutput(*prop\img))
DrawingFont(*prop\TextFont)
*prop\TextX = (*prop\Width-1-TextWidth("100 %"))/2
*prop\TextY = (*prop\Height-TextHeight(" "))/2 ;+ 1
StopDrawing()
EndIf
EndIf
EndProcedure
; Test.
hWnd=OpenWindow(0, 0, 0, 300, 150, "PercentBarGadget", #PB_Window_SystemMenu|#PB_Window_ScreenCentered)
If hwnd
PercentBarGadget(0, 10, 20, 280, 25, -100, 900)
PercentBarGadget(1, 10, 60, 280, 45, 1000, 1500)
PercentBarGadget(2, 10, 120, 280, 25, 0, 300)
SetPercentBarColor(0, $951225, $EBA6B1, $E07181)
SetPercentBarFont(1, "MS Sans Serif", 20, #PB_Font_Italic|#PB_Font_HighQuality)
SetPercentBarColor(2, #PB_Default, #PB_Default, $9922FF)
v=-100
w=1000
x=0
Repeat
e=WindowEvent()
v+1
w+1
x+1
SetPercentBarValue(0, v)
SetPercentBarValue(1, w)
SetPercentBarValue(2, x)
If v>=900 : v=-100 : EndIf
If w>=1500 : w=1000 : EndIf
If x>=300 : x=0 : EndIf
Delay(1)
Until e=#PB_Event_CloseWindow
EndIf
End
- Fangbeast
- PureBasic Protozoa
- Posts: 4791
- Joined: Fri Apr 25, 2003 3:08 pm
- Location: Not Sydney!!! (Bad water, no goats)
Nice stuff but all this seems to be for pb 3.94. When I change the obvious for pb4, I stull get errors I don't know how to handle like an error message about Locate() not being an array, linked list etc.
Can anyone convert all this to pb4?
Can anyone convert all this to pb4?
Amateur Radio/VK3HAF, (D-STAR/DMR and more), Arduino, ESP32, Coding, Crochet