
Code: Select all
Structure ProgressBarEx
GadgetID.l
x.l
y.l
w.l
h.l
min.l
max.l
state.l
EndStructure
Global NewList ProgressBarsEx.ProgressBarEx()
Procedure ProgressBarGadgetEx(GadgetID,x,y,w,h,min,max)
AddElement(ProgressBarsEx())
ProgressBarsEx()\GadgetID.l = GadgetID
ProgressBarsEx()\x.l = x
ProgressBarsEx()\y.l = y
ProgressBarsEx()\w.l = w
ProgressBarsEx()\h.l = h
ProgressBarsEx()\min.l = min
ProgressBarsEx()\max.l = max
ProgressBarsEx()\state.l = 0
;Startup Image
PImage = CreateImage(#PB_Any,w,h)
StartDrawing(ImageOutput(PImage))
Box(0,0,w,h,RGB(255,255,255))
Line(0,0,w-1,0,RGB(160,160,160))
Line(0,0,0,h,RGB(160,160,160))
Line(1,h-1,w-1,0,RGB(134,134,134))
Line(w-1,0,0,h,RGB(134,134,134))
Line(1,1,w-2,0,RGB(225,225,225))
Line(1,h-2,w-2,0,RGB(169,169,169))
Line(1,2,0,h-4,RGB(178,178,178))
Line(w-2,2,0,h-4,RGB(178,178,178))
Box(2,2,w-4,h-4,RGB(192,192,192))
StopDrawing()
Handle = ImageGadget(GadgetID,x,y,w,h,ImageID(PImage))
If IsImage(PImage)
FreeImage(PImage)
EndIf
ProcedureReturn Handle
EndProcedure
Procedure SetProgressExBarState(GadgetID.l,State.l)
If state = 0
ProcedureReturn
EndIf
ForEach ProgressBarsEx()
If ProgressBarsEx()\GadgetID = GadgetID
ProgressBarsEx()\State = State
SPImage = CreateImage(#PB_Any,ProgressBarsEx()\w,ProgressBarsEx()\h)
StartDrawing(ImageOutput(SPImage))
Box(0,0,ProgressBarsEx()\w,ProgressBarsEx()\h,RGB(255,255,255))
Line(0,0,ProgressBarsEx()\w-1,0,RGB(160,160,160))
Line(0,0,0,ProgressBarsEx()\h,RGB(160,160,160))
Line(1,ProgressBarsEx()\h-1,ProgressBarsEx()\w-1,0,RGB(134,134,134))
Line(ProgressBarsEx()\w-1,0,0,ProgressBarsEx()\h,RGB(134,134,134))
Line(1,1,ProgressBarsEx()\w-2,0,RGB(225,225,225))
Line(1,ProgressBarsEx()\h-2,ProgressBarsEx()\w-2,0,RGB(169,169,169))
Line(1,2,0,ProgressBarsEx()\h-4,RGB(178,178,178))
Line(ProgressBarsEx()\w-2,2,0,ProgressBarsEx()\h-4,RGB(178,178,178))
Box(2,2,ProgressBarsEx()\w-4,ProgressBarsEx()\h-4,RGB(192,192,192))
w = ProgressBarsEx()\w / 100 * ProgressBarsEx()\State
h = ProgressBarsEx()\h
Line(0,0,w-1,0,RGB(230,136,136))
Line(0,0,0,h,RGB(230,136,136))
Line(1,h-1,w-1,0,RGB(143,0,0))
Line(w-1,0,0,h,RGB(143,0,0))
Line(1,1,w-2,0,RGB(216,64,64))
Line(1,h-2,w-2,0,RGB(177,0,0))
Line(1,2,0,h-4,RGB(211,34,34))
Line(w-2,2,0,h-4,RGB(211,34,34))
Box(2,2,w-4,h-4,RGB(204,0,0))
StopDrawing()
SetGadgetState(ProgressBarsEx()\GadgetID,ImageID(SPImage))
If IsImage(SPImage)
FreeImage(SPImage)
EndIf
EndIf
Next
ProcedureReturn 0
EndProcedure
Procedure Demo(Dummy.l)
Repeat
If Statev = 100
Statev =0
EndIf
SetProgressExBarState(5,Statev)
Statev + 1
Delay(10)
ForEver
EndProcedure
If OpenWindow(0, 0, 0, 300, 50, "BitDefender-style progressbar",#PB_Window_SystemMenu | #PB_Window_ScreenCentered) And CreateGadgetList(WindowID(0))
ProgressBarGadgetEx(5,50,15,200,20,0,100)
CreateThread(@Demo(),0)
Repeat
event = WaitWindowEvent()
Until event = #PB_Event_CloseWindow
End
EndIf