Progress Bar Demo - Using MSchedv12

Example scripts and tips (replaces Old Scripts & Tips archive)

Moderators: Dorian (MJT support), JRL, Phil Pendlebury

Post Reply
User avatar
Phil Pendlebury
Automation Wizard
Posts: 538
Joined: Tue Jan 16, 2007 9:00 am
Contact:

Progress Bar Demo - Using MSchedv12

Post by Phil Pendlebury » Mon May 17, 2010 8:13 pm

Demo of progress bar usage. Showing vertical progress bars and some other interesting things using the new v12 dialog system.

Code: Select all

////////////////////////////////////////////////////////////////////////////////////////////////
// Progress Bar v1.01 as Timer demo by Phil Pendlebury - http://www.pendlebury.biz/
////////////////////////////////////////////////////////////////////////////////////////////////

Dialog>TimerD
object TimerD: TForm
  Left = 550
  Top = 419
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Timer'
  ClientHeight = 241
  ClientWidth = 328
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poScreenCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object Label1: TLabel
    Left = 264
    Top = 32
    Width = 54
    Height = 13
    Caption = 'Loop Delay'
  end
  object ProgressBar1: TProgressBar
    Left = 8
    Top = 32
    Width = 25
    Height = 201
    Max = 10
    Orientation = pbVertical
    MarqueeInterval = 1
    TabOrder = 6
  end
  object ProgressBar2: TProgressBar
    Left = 48
    Top = 32
    Width = 57
    Height = 201
    Max = 60
    Orientation = pbVertical
    MarqueeInterval = 1
    TabOrder = 7
  end
  object ProgressBar3: TProgressBar
    Left = 120
    Top = 32
    Width = 57
    Height = 201
    Max = 60
    Orientation = pbVertical
    MarqueeInterval = 1
    TabOrder = 9
  end
  object ProgressBar4: TProgressBar
    Left = 192
    Top = 32
    Width = 57
    Height = 201
    Max = 10
    Orientation = pbVertical
    MarqueeInterval = 1
    TabOrder = 0
  end
  object Edit1: TEdit
    Left = 8
    Top = 7
    Width = 25
    Height = 21
    Enabled = False
    TabOrder = 1
    Text = '0'
  end
  object Edit2: TEdit
    Left = 48
    Top = 8
    Width = 57
    Height = 21
    Enabled = False
    TabOrder = 2
    Text = '0'
  end
  object Edit3: TEdit
    Left = 120
    Top = 8
    Width = 57
    Height = 21
    Enabled = False
    TabOrder = 3
    Text = '0'
  end
  object Edit4: TEdit
    Left = 192
    Top = 8
    Width = 57
    Height = 21
    Enabled = False
    TabOrder = 4
    Text = '0'
  end
  object MSButton1: tMSButton
    Left = 264
    Top = 200
    Width = 57
    Height = 33
    Caption = 'GO!'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 5
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object MSButton2: tMSButton
    Left = 264
    Top = 104
    Width = 57
    Height = 33
    Caption = 'PAUSE'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 8
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object Edit5: TEdit
    Left = 264
    Top = 57
    Width = 57
    Height = 21
    TabOrder = 10
    Text = '0.084'
  end
  object MSButton3: tMSButton
    Left = 264
    Top = 152
    Width = 57
    Height = 33
    Caption = 'RESET'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 19
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>TimerD

AddDialogHandler>TimerD,MSButton1,OnClick,BEGIN
AddDialogHandler>TimerD,MSButton2,OnClick,PAUSE
AddDialogHandler>TimerD,MSButton3,OnClick,RESET
AddDialogHandler>TimerD,Edit5,OnChange,CHANGE
AddDialogHandler>TimerD,,OnClose,CLOSE
Show>TimerD,result

SRT>BEGIN
  Let>ms=0
  Let>se=0
  Let>mi=0
  Let>ho=0
  Let>delay=0.084
  //
  Label>LMS
    GOSUB>DRAW
    Let>ms=ms+1
    IF>ms>10
      LET>ms=1
      LET>se=se+1
      IF>se>60
        LET>se=1
        LET>mi=mi+1
        IF>mi>60
          LET>mi=1
          LET>ho=ho+1
        ENDIF
      ENDIF
    ENDIF
    // There are definitely more accurate ways to do this but this is a demo of the progress bar not of timer accuracy
    Wait>%delay%
  GOTO>LMS
END>BEGIN

SRT>DRAW
// Draw the Progress Bars
SetDialogProperty>TimerD,ProgressBar1,Position,%ms%
SetDialogProperty>TimerD,Edit1,Text,%ms%
SetDialogProperty>TimerD,ProgressBar2,Position,%se%
SetDialogProperty>TimerD,Edit2,Text,%se%
SetDialogProperty>TimerD,ProgressBar3,Position,%mi%
SetDialogProperty>TimerD,Edit3,Text,%mi%
SetDialogProperty>TimerD,ProgressBar4,Position,%ho%
SetDialogProperty>TimerD,Edit4,Text,%ho%
END>DRAW

SRT>PAUSE
  MDL>PAUSED %ho%:%mi%:%se%.%ms%
END>PAUSE

SRT>CHANGE
  GetDialogProperty>TimerD,Edit5,Text,delay
  IF>delay>5
   LET>delay=5
  ENDIF
END>CHANGE

SRT>RESET
  Let>ms=0
  Let>se=0
  Let>mi=0
  Let>ho=0
  SetDialogProperty>TimerD,ProgressBar1,Position,%ms%
  SetDialogProperty>TimerD,Edit1,Text,%ms%
  SetDialogProperty>TimerD,ProgressBar2,Position,%se%
  SetDialogProperty>TimerD,Edit2,Text,%se%
  SetDialogProperty>TimerD,ProgressBar3,Position,%mi%
  SetDialogProperty>TimerD,Edit3,Text,%mi%
  SetDialogProperty>TimerD,ProgressBar4,Position,%ho%
  SetDialogProperty>TimerD,Edit4,Text,%ho%
  Let>delay=0.084
  SetDialogProperty>TimerD,Edit5,Text,%delay%
END>RESET

SRT>CLOSE
  Exit>0
END>CLOSE
Phil Pendlebury - Linktree

Post Reply
Sign up to our newsletter for free automation tips, tricks & discounts