A simple themed progressbar

Published on by Yousfi Benameur

In this recent article  "Generate gradients images with APIs"
http://yousfi.over-blog.com/2015/01/generate-gradients-images-with-apis.html
we made code to build images with gradients colors.Can be small dimensions.
Now we can use these images to build a simple progressbar .I chose 5 images to do the job and embed them in the yprogressbar class as encoded.The code decodes them and use the image.pictureVAL property to rebuild them as a normal picture.
the image is stretched to 2 and a timer make the progression.
All these are in the prg below.can rebuild visual objects with this easily.

see some screenshots below.

*Please correct the end line marked &&& below with '999%'] (pb rendered text  editor)

*Begin code

publi yform
yform=newObject("yprog")
yform.show
read events
retu
*
DEFINE CLASS yprog AS form
    BorderStyle = 2
    Height = 250
    Width = 407
    ShowWindow = 2
    ShowTips = .T.
    AutoCenter = .T.
    Backcolor=rgb(196,217,111)
    Caption = "A simple themed progressbar"
    MaxButton = .F.
    Name = "Form1"

    ADD OBJECT yprogressbar1 AS yprogressbar WITH ;
        Top = 15, ;
        Left = 26, ;
        Name = "Yprogressbar1", ;
        Image1.Name = "Image1", ;
        Timer1.Name = "Timer1", ;
        Label1.Name = "Label1"

    ADD OBJECT command2 AS commandbutton WITH ;
        Top = 135, ;
        Left = 122, ;
        Height = 37, ;
        Width = 109, ;
        FontSize = 12, ;
      
 Caption = "GO !", ;
       Mousepointer=15, ;
        ForeColor = RGB(255,0,0), ;
        BackColor = RGB(0,255,0), ;
        Name = "Command2"

    ADD OBJECT spinner1 AS spinner WITH ;
        Height = 37, ;
        KeyboardHighValue = 6, ;
        KeyboardLowValue = 1, ;
        Left = 242, ;
        SpinnerHighValue =   6.00, ;
        SpinnerLowValue =   1.00, ;
        ToolTipText = "themes  (1-5)", ;
        Top = 135, ;
        Width = 37, ;
        Value = 1, ;
        Name = "Spinner1"

    PROCEDURE command2.Click
        thisform.yprogressbar1.ycall(thisform.spinner1.value)
    ENDPROC
    
    PROCEDURE DESTROY
    CLEA EVENTS
    ENDPROC

ENDDEFINE


*yProgressbar here
DEFINE CLASS yprogressbar AS container
    Width = 349
    Height = 61
    BackStyle = 1
   
SpecialEffect = 1
    Borderwidth=0
    Visible = .F.
    BackColor = RGB(0,0,0)
    Name = "yprogressbar"

    ADD OBJECT image1 AS image WITH ;
        Stretch = 2, ;
        Height = 60, ;
        Left = 0, ;
        Top = 0, ;
        Width = 48, ;
        Name = "Image1"

    ADD OBJECT timer1 AS timer WITH ;
        Top = 12, ;
        Left = 312, ;
        Height = 23, ;
        Width = 23, ;
        Enabled = .F., ;
        Interval = 100, ;
        Name = "Timer1"

    ADD OBJECT label1 AS label WITH ;
        FontBold = .T., ;
        FONTNAME="ARIAL BLACK",;
        FontSize = 14, ;
        BackStyle = 0, ;
        Caption = "", ;
        Height = 37, ;
        Left = 137, ;
        Top = 19, ;
        Width = 85, ;
        ForeColor = RGB(255,0,0), ;
        Name = "Label1"

    PROCEDURE ycall
        lparameters num

        if pcount()=0 or empty(num)
        return .f.
        endi

        if  !inlist(num,1,2,3,4,5,6)
        num=1
        endi
        declare integer  Sleep in kernel32 integer
        local m.myvar

        do case
        case num=1

        text to m.myvar  noshow
        iVBORw0KGgoAAAANSUhEUgAAAOUAAAAfCAIAAACXop0+AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAbKSURBVHhe7Zz5T5N3GMD744aj4jHdMtsCmkwRBI0Xt1AoaEyWiRy9b64q0lZQdDMwDik9KdDS0gMoIOPSORUFVKYIosghCFLRmUWN2V+x5/u+ePwDvvvlm3zyyfM8b8pPn7whJJTGDN26gbEjiLEriBEB0JkRgayIQOYuOgKtGAwFkNWRQHvrGBHrGDuBIOZOOhO8YyNj2+YtwbT1rO3eEb/p5j/W2++NQ2/MQ2/qR96Zh97Cahl+b8ZgqGHknWX4LfDh8q9xBGGALFGQLz0ji4HBkbS1rF26P1+c8L3I8/2taF3Ja/cX+vz5rcsFbTC/wmCoYqWgzQ/AnNv+GlD6XssJlL6VU50L5htLX4fuh17D4Z2qbH8ha30JKNr8uW3LCu+ysnUFgIIxGA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JjOZxzhvxIGt9z7Dmzr3n7H3TWvuVsPKpMgCwvDoDIMujbwBkuQ0NgCyXsQGQ5TQ1ALIc5gZAlt3SAMiyWRsAWVZbAyDLYm8AZJkdDYAsk7MBkGV0NQCyDO4GQJbe0wDI0r0NgCz1NQAynwBwvgPA+RUA5zkAnCeBcN4FwHkbCOc8AJwTQXDOBMI5FQznXgCcm0Fw7gbCuR0M5/8B0Kr+3ls7QHE8Y0kAAAAASUVORK5CYII=
        endtext

        case num=3
        text to m.myvar  noshow
        iVBORw0KGgoAAAANSUhEUgAAAIEAAAAiCAIAAAD3Si1HAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACpSURBVGhD7dorDkJBFIPh2uuxaDQajUaj0Vg0Go0muXBfy8R3Aa35k28Hk8yZOa2kEW3DiDLtvijT/osyHX4o0/GHMp0mlOk8oUyXCWW6TijTbUaZ7jPK9FhQpueCMr1WlOm9okyfDWXaNpT5mSDP7ybk+YxGnr9Vked/NuT57gJ5vsNDnu+ykeeZDvI820SeZ/zI864L8rzzhTzvPiLPO8DI8y48wobxDzLSnWgHgZKZAAAAAElFTkSuQmCC
        endtext

        case num=4
        text to m.myvar  noshow
        iVBORw0KGgoAAAANSUhEUgAAAIAAAAAiCAIAAAAYiEZ5AAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAACqSURBVGhD7dshbgJAFEXRa6ux1bVYdG0VAgwCFEmDISQYEBgQGEwNGBKCYZllF9fc5GxhMvP+f8OYR0RMuUbEjEtELDhFxJJ9RKzYRMSa34jYMo+IHZOIOPATEUe+I+LMKKJ3FBtGxB9fEXHjMyLuDCLiyUdEvIipEyDrDpD1CpKVA2QlYVmzIFnTUFn7AFkbMVk7YVmtCFm9IFnNOFndUFntaFn/A1Rc/wG3YJzESv808QAAAABJRU5ErkJggg==
        endtext

        case num=5
        text to m.myvar  noshow
        iVBOR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T9wpDbK1sAAAAASUVORK5CYII=
        endtext

case num=6
        text to m.myvar noshow
        iVBORw0KGgoAAAANSUhEUgAAAGsAAAAbCAIAAAD0/+aaAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsMAAA7DAcdvqGQAAAJESURBVGhD7dSxahRBAIfxe4k7dy+5JWCVmFII+ABa2ElQ7AJJc6JgY2NaCz2xMAdJEVRQ04RAEkgbECvBwi7PkzluWYcve9/Mpb7lV2XmY+DPkU632+31encW322/TpivqpZH4+Hln4O/V0c5fv/bz4fWoXVoHVqH9qaw1Wj8YmWlKsuyUxTFh73h6a83X86f7p88Tnr3dT0fWofWoXVoHdpWYauw2Pu9Yb3gz4tXuDELHnNoHVqH1qF1aN3B8fN+vz9Z8PBsE2et8JhD69A6tA6tQ+vC/dGPjcmC4XeIs1bxS0loHVqH1qF1aF1T5S7YBDnQOrQOrUPr0Lo4zFowDpLQOrQOrUPr0Dq06QUROLQOrUPr0Dq0Dm2QWBC3HVqH1qF1aB1ah3bKFsRVh9ahdWgdWofWoW3MXBD3HFqH1qF1aB1ahzbWviAuObQOrUPr0Dq0Di20LIgbLg6T0Dq0Dq1D69DexAVx7JoqB1qH1qF1aB3aVv8XxIGLn0lC69A6tA5tEvJZFgu2QyvqBfFXh8ccWofWoXVoHVo394J4zKF1aB1ah9ahdeH+fAvGLyWhdWgdWofWoXXTZI4Fm2dyoHVoHVqH1qF1TZW7YBPkQOvQOrQOrUPr4jBrwThIQuvQOrQOrUPr0E4WLIri7ed7uNdA4NA6tA6tQ+vQOrQfvz2sF3y2s4qrUwgcWofWoXVoHVqHNth+/aBecDBYerJ1d3e85oGIwyS0Dq1D69A6tJ++P9p6eb+qlusFw7/CxXfLryyvAYuRNGHb/CU1AAAAAElFTkSuQmCC
        endtext
        endcase

        with this.image1
        .pictureVAl=strconv(m.myvar,14)
        .width=0
        endwith

        with this
        .visible=.t.
        .timer1.enabled=.t.
        endwith
    ENDPROC

    PROCEDURE image1.Init
        this.width=0
        this.left=0
    ENDPROC

    PROCEDURE timer1.Timer
        local m.x,m.val
        m.delta=3
        with this.parent.image1
        .parent.label1.zorder(0)
        .width=.width+m.delta
        m.val=100*.width/.parent.width
      
  if m.val<=100
        .parent.label1.caption=;
trans[100*.width/.parent.width,'999 %' ]  &&&
correct end here (pb editor)
        else
        .parent.label1.caption=;
trans[100,'999 %']
        endi

        if .width>=.parent.width
        this.enabled=.f.
        sleep(1000)
        .width=0
        this.parent.visible=.f.

        endi
        endwith
    ENDPROC

ENDDEFINE
*

*End code

A simple themed progressbar
A simple themed progressbar
A simple themed progressbar
A simple themed progressbar
A simple themed progressbar
A simple themed progressbar
A simple themed progressbar