INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Jobs

CLASS

A Progress Bar or Thermometer Class by ramani
Posted: 16 Nov 04

*********************************************************
** gsThermometer by Subramanian.G (ramani)
**    www.winnersoft.coolfreepages.com
**    FoxAcc Software - ramani_g@yahoo.com
** provided as freeware. Use at your Own Risk.
*********************************************************
* How to use .... (Example)
* Progress Bar or Thermometer Class and how to use .. example
*
* Copy the following and run the PRG

DEFINE POPUP gsTherm SHORTCUT RELATIVE FROM MROW(),MCOL() ;
    STYLE "BOLDITALIC" FONT "Arial",12 ;
    TITLE "Thermometer Demo" MARGIN

DEFINE BAR 1 OF gsTherm PROMPT "Thermometer using labels"
DEFINE BAR 2 OF gsTherm PROMPT "Thermometer using OLE class"
DEFINE BAR 3 OF gsTherm PROMPT "Thermometer using container"
DEFINE BAR 4 OF gsTherm PROMPT "Exit"

ON SELECTION POPUP gsTherm DEACTIVATE POPUP
*****************************************************
DO WHILE .t.
    ACTIVATE POPUP gsTherm
    DO CASE
        CASE BAR()=1
            cThermometer = 'gsThermometer'
        CASE BAR()=2
            cThermometer = 'gsThermometerOLE'
        CASE BAR()=3
            cThermometer = 'gsThermometerBar'
        CASE BAR()=4
            EXIT
    ENDCASE
**
    oTherm = createobject(cThermometer)
    oTherm.Show()
    FOR I = 1 TO 100
        a = inkey(.01)
        oTherm.Progress1.Value = i
    ENDFOR
    oTherm.Release
**
ENDDO
RETURN
**************************************************
* The above code is for showing example
* Choose the thermometer you like and implement.
*
*  Suitably insert lines in your code to set the
*  oThermometer.Progress1.Value a % completed.
*
*
**************************************************
** The following shows the
** A combination of Labels as growing for progress bar.
**************************************************
*-- Class:        gstherm
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   11/13/04 12:58:04 PM
*
DEFINE CLASS gsThermometer AS form

    Height = 76
    Width = 500
    AutoCenter = .T.
    BackColor = RGB(240,240,240)
    BorderStyle = 0
    Caption = ""
    Closable = .F.
    ControlBox = .F.
    MaxButton = .F.
    MinButton = .F.
    Movable = .F.
    AlwaysOnTop = .f.
    ShowWindow = 1
    Name = "gsThermometer"


    ADD OBJECT ShapeOuter AS shape WITH ;
        Top = 2, ;
        Left = 2, ;
        Height = 72, ;
        Width = 496, ;
        BackStyle = 0, ;
        BorderWidth = 4, ;
        Curvature = 5, ;
        SpecialEffect = 0, ;
        BorderColor = RGB(0,128,0), ;
        Style = 0, ;
        Name = "ShapeOuter"


    ADD OBJECT Image1 AS image WITH ;
        Picture = ADDBS(HOME(4))+[Bitmaps\Assorted\Beany.bmp], ;
        BackStyle = 0, ;
        Height = 64, ;
        Left = 10, ;
        Top = 6, ;
        Width = 64, ;
        Name = "Image1"


    ADD OBJECT Progress1 AS textbox WITH ;
        Value = 1, ;
        Visible = .F., ;
        Name = "Progress1"


    ADD OBJECT lblProgress AS label WITH ;
        FontBold = .T., ;
        BackStyle = 0, ;
        Caption = "Progress", ;
        Height = 14, ;
        Left = 81, ;
        Top = 18, ;
        Width = 384, ;
        ForeColor = RGB(0,128,0), ;
        Name = "lblProgress"


    ADD OBJECT ShapeProgress AS shape WITH ;
        Top = 32, ;
        Left = 77, ;
        Height = 32, ;
        Width = 408, ;
        BackStyle = 1, ;
        SpecialEffect = 0, ;
        BackColor = RGB(255,255,240), ;
        Name = "ShapeProgress"


    ADD OBJECT Label1 AS label WITH ;
        FontBold = .T., ;
        FontSize = 24, ;
        BackStyle = 0, ;
        Caption = (REPLICATE("I",50)), ;
        Height = 30, ;
        Left = 81, ;
        Top = 29, ;
        Width = 404, ;
        ForeColor = RGB(192,192,192), ;
        Name = "Label1"


    ADD OBJECT Label2 AS label WITH ;
        FontBold = .T., ;
        FontSize = 24, ;
        BackStyle = 0, ;
        Caption = "Label2", ;
        Height = 30, ;
        Left = 79, ;
        Top = 29, ;
        Width = 404, ;
        ForeColor = RGB(0,192,0), ;
        Name = "Label2"


    ADD OBJECT Label3 AS label WITH ;
        FontBold = .T., ;
        FontSize = 24, ;
        BackStyle = 0, ;
        Caption = "Label3", ;
        Height = 30, ;
        Left = 81, ;
        Top = 29, ;
        Width = 404, ;
        ForeColor = RGB(0,192,0), ;
        Name = "Label3"


    PROCEDURE Destroy
        SET CURSOR ON
    ENDPROC


    PROCEDURE Init
        * Simply Set This.Progress1.Value = % completed to display suitably.
        *
        This.Progress1.Value = 0
        SET CURSOR OFF
        This.zOrder(0)
        INKEY(0.001)
    ENDPROC


    PROCEDURE progress1.ProgrammaticChange
        This.Parent.Label2.Caption = REPLICATE("I",This.Value/2)
        This.Parent.Label3.Caption = REPLICATE("I",This.Value/2)
        INKEY(0.001)
    ENDPROC


ENDDEFINE
*
*-- EndDefine: gstherm
**************************************************
*
*
*
*
*
**************************************************
** The following shows the
** OLE class-Microsoft Progressbar Control Ver 5.0 (SP2)
** way of showing a progress bar.
**************************************************
**************************************************
** gsThermometerOLE
**************************************************
*-- Form:         gsThermometerOLE
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   11/10/04 12:01:04 AM
*
DEFINE CLASS gsThermometerOLE AS form

    Height = 70
    Width = 408
    AutoCenter = .T.
    BackColor = RGB(240,240,240)
    BorderStyle = 3
    Caption = ""
    Closable = .F.
    ControlBox = .F.
    MaxButton = .F.
    MinButton = .F.
    Movable = .F.
    AlwaysOnTop = .f.
    ShowWindow = 1
    Name = "gsThermometer"

    ADD OBJECT shape1 AS shape WITH ;
        Curvature = 10, ;
        Top = 6, ;
        Left = 6, ;
        Height = 58, ;
        Width = 396, ;
        Name = "Shape1"

    ADD OBJECT lblProgress AS label WITH ;
        BackStyle = 0, ;
        Caption = "Progress", ;
        ForeColor = RGB(0,128,0), ;
        Height = 14, ;
        Left = 12, ;
        Top = 12, ;
        Width = 384, ;
        Name = "lblProgress"

    ** OLE class-Microsoft Progressbar Control Ver 5.0 (SP2)
    ADD OBJECT Progress1 AS olecontrol WITH ;
        Top = 28, ;
        Left = 12, ;
        Height = 30, ;
        Width = 384, ;
        OleClass = 'comctl.ProgCtrl.1', ;
        Name = "Progress1"

    PROCEDURE Destroy
        SET CURSOR ON
    ENDPROC

    PROCEDURE Init
        * Simply Set This.Progress1.Value = % completed to display suitably.
        *
        This.Progress1.Value = 0
        SET CURSOR OFF
        This.zOrder(0)
        INKEY(0.001)
    ENDPROC

ENDDEFINE
*
*-- EndDefine: gsThermometerOLE
**************************************************
*
*
*
*
*
**************************************************
** The following shows  
** A Container as a growing bar for progress bar.
**************************************************
**************************************************
** gsThermometerBar
**************************************************
*-- Form:         gsThermometerBar
*-- ParentClass:  form
*-- BaseClass:    form
*-- Time Stamp:   11/10/04 12:01:04 AM
*
DEFINE CLASS gsThermometerBar AS form

    Height = 70
    Width = 408
    AutoCenter = .T.
    BackColor = RGB(240,240,240)
    BorderStyle = 3
    Caption = ""
    Closable = .F.
    ControlBox = .F.
    MaxButton = .F.
    MinButton = .F.
    Movable = .F.
    AlwaysOnTop = .f.
    ShowWindow = 1
    Name = "gsThermometer"

    ADD OBJECT shape1 AS shape WITH ;
        Curvature = 10, ;
        Top = 6, ;
        Left = 6, ;
        Height = 58, ;
        Width = 396, ;
        Name = "Shape1"

    ADD OBJECT lblProgress AS label WITH ;
        BackStyle = 0, ;
        Caption = "Progress", ;
        ForeColor = RGB(0,0,128), ;
        Height = 14, ;
        Left = 12, ;
        Top = 12, ;
        Width = 384, ;
        Name = "lblProgress"

    ADD OBJECT Progress1 AS textbox WITH ;
        Value = 1, ;
        Visible = .F., ;
        Name = "Progress1"

    ADD OBJECT ProgressBarBack AS Container WITH ;
        SpecialEffect = 1, ;
        Top = 29, ;
        Left = 12, ;
        Height = 24, ;
        Width = 384, ;
        Name = "ProgressBarBack"

    ADD OBJECT ProgressBar AS container WITH ;
        BackColor = RGB(224,0,0), ;
        BackStyle = 1, ;
        BorderWidth = 0, ;
        Top = 31, ;
        Left = 14, ;
        Height = 20, ;
        Width = 380, ;
        Name = "ProgressBar"

    ADD OBJECT ProgressPercent AS Label WITH ;
        BackStyle = 0, ;
        BorderStyle = 0, ;
        FontItalic = .t., ;
        FontSize = 9, ;
        ForeColor = RGB(0,0,128), ;
        Top = 34, ;
        Left = 192, ;
        Height = 18, ;
        Width = 36, ;
        Name = "ProgressPercent"

    PROCEDURE Destroy
        SET CURSOR ON
    ENDPROC

    PROCEDURE Init
        * Simply Set This.Progress1.Value = % completed to display suitably.
        *
        This.Progress1.Value = 0
        SET CURSOR OFF
        This.zOrder(0)
        INKEY(0.001)
    ENDPROC

    PROCEDURE progress1.ProgrammaticChange
        * 380 is the Max width of the Progress Bar when 100% completed.
        This.Parent.ProgressBar.Width = (This.Value * 380)/100
        This.Parent.ProgressPercent.Caption = TRANSFORM(This.Value)+'%'
        INKEY(0.001)
    ENDPROC

ENDDEFINE
*
*-- EndDefine: gsThermometerBar
**************************************************

Back to Microsoft: Visual FoxPro FAQ Index
Back to Microsoft: Visual FoxPro Forum

My Archive

Resources

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close