Page 2 of 2

Posted: Mon May 01, 2006 11:59 am
by srod
breeze4me's code works okay here. Nice work by the way, I'll make use of this. :D

Posted: Mon May 29, 2006 6:46 am
by dagcrack

Code: Select all

;PercentBar 
;2005 by Hroudtwolf 
;Progressbar with percentdisplay 
; 
;Declaring all needed procedures 
Declare Setpercents (Gadget.l,Position.l,gadgetreturn$) 
Declare.s PercentbarGadget (Gadget.l,x.l,y.l,pcwidth.l,pcheigth.l,max.l) 

hwnd.l = OpenWindow(0, 100, 100, 300, 60, "PercentBar", #PB_Window_TitleBar|#PB_Window_ScreenCentered) 
If hwnd.l 
  If CreateGadgetList (hwnd.l) 
    info$=PercentbarGadget (1,10,20,280,20,40); PercentGadget erstellen(creating  the percentgadget) 
  EndIf 
  Repeat 
    EventID.l = WindowEvent() 
    Setpercents (1,xx,info$); Das PercentGadget aktualisieren;(actualizing the p-gadget) 
    xx=xx+1 
    If xx>40:xx=0:EndIf 
    Delay(100) 
  Until EventID = #PB_Event_CloseWindow 
  
EndIf 
End 

;The PercentGadget 
Procedure.s PercentbarGadget (Gadget.l,x.l,y.l,pcwidth.l,pcheight.l,max.l) 
  gadgetreturn$=Str(pcwidth.l)+"|"+Str(pcheight.l)+"|"+Str(max.l) 
  Setpercents (Gadget.l,0,gadgetreturn$) 
  ImageGadget (Gadget.l,x.l,y.l,pcwidth.l,pcheigth.l,ImageID (800+Gadget.l)) 
  ProcedureReturn gadgetreturn$ 
EndProcedure 

;Actualizer for the Percentgadget 
Procedure Setpercents (Gadget.l,Position.l,gadgetreturn$) 
  pcwidth.l=Val(StringField(gadgetreturn$, 1, "|")) 
  pcheight.l=Val(StringField(gadgetreturn$, 2, "|")) 
  max.l=Val(StringField(gadgetreturn$, 3, "|")) 
  ;Prozentberechnung 
  onepercent.f=max/100 
  If onepercent.f=0:onepercent.f=1:EndIf 
  percent.l=Position.l/onepercent.f 
  
  ;Systemfarben ermitteln(get the systemcolors) 
  HFarbe.l=GetSysColor_(#COLOR_BTNFACE ) 
  RFarbe1.l=GetSysColor_(#COLOR_3DHIGHLIGHT) 
  RFarbe2.l=GetSysColor_(#COLOR_3DSHADOW) 
  TFarbe.l=GetSysColor_(#COLOR_BTNTEXT ) 
  ;Gadgetstyle erstellen (making the gadgetstyle) 
  If IsImage (800+Gadget.l)=0:CreateImage (800+Gadget.l,pcwidth.l,pcheight.l):EndIf 
  If StartDrawing (ImageOutput (800+Gadget.l)) 
    DrawingMode(0) 
    Box (0,0,pcwidth.l,pcheight.l,HFarbe.l) 
    Line (0,0,0,pcheight.l,RFarbe2.l) 
    Line (0,0,pcwidth.l,0,RFarbe2.l) 
    Line (0,pcheight.l-1,pcwidth.l,0,RFarbe1.l) 
    Line (pcwidth.l-1,0,0,pcheight.l,RFarbe1.l) 
    Box (1,1,((pcwidth.l*Position)/max)-2,pcheight.l-2,RGB(100,100,250)) 
    For x=10 To pcwidth.l-10 Step 10 
      Line (x,1,0,pcheight.l-2,HFarbe.l) 
    Next x 
    DrawingMode(1) 

    rot.l=Red(TFarbe.l) 
    gruen.l=Green(TFarbe.l) 
    blau.l=Blue(TFarbe.l) 
    FrontColor (RGB(rot.l,gruen.l,blau.l)) 
    Text$=Str(percent.l)+ " %" 
    DrawText (Int(pcwidth.l/2)-20,2,Text$) 
    StopDrawing () 
  EndIf 
  If IsGadget (Gadget.l):SetGadgetState (Gadget.l,ImageID (800+Gadget.l)):EndIf 
EndProcedure
Doesnt that work in PB4?

Posted: Mon May 29, 2006 9:42 am
by gnozal
Fangbeast wrote: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?
The above code from breeze4me works for me with PB4.00 final.

Posted: Mon May 29, 2006 11:08 am
by Psychophanta
gnozal wrote:
Fangbeast wrote: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?
The above code from breeze4me works for me with PB4.00 final.
Confirmed.
Fangbeast seems to have drunk too much beer or something :P

Posted: Mon May 29, 2006 1:55 pm
by Fangbeast
Psychophanta wrote:
gnozal wrote:
Fangbeast wrote: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?
The above code from breeze4me works for me with PB4.00 final.
Confirmed.
Fangbeast seems to have drunk too much beer or something :P
I don't drink alcohol. Must have been your armpits making my glasses fog up and my eyestalks crossed. :D :D