Slider & Dialog Display Example - MSched v12

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

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

Post Reply
User avatar
Rain
Automation Wizard
Posts: 550
Joined: Tue Aug 09, 2005 5:02 pm
Contact:

Slider & Dialog Display Example - MSched v12

Post by Rain » Wed Nov 17, 2010 4:48 pm

Image

Submitted by: Rain

Macro Scheduler Version: 12

Description: Slider to get a numeric value between 0 and 100.
I created this Slider with 2 splitters inside a Panel to keep it compact and so it can be placed anywhere inside a form. In this example the slider displays a numeric value between 0 and 100 in a Label and Status Bar, and changes the position of a Horizontal and Vertical Progress Bar by retrieving the position of the slider/splitter inside the Panel. Adjust the width of Panel1 to increase or decrease the maximum numeric value.

Please see remarks inside the script.

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 472
  Top = 152
  HelpContext = 5000
  BorderWidth = 2
  Caption = 'Slider & Display Example by Rain'
  ClientHeight = 150
  ClientWidth = 350
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  Position = poDesktopCenter
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object SliderDisplayLabel: TLabel
    Left = 24
    Top = 48
    Width = 68
    Height = 13
    Caption = 'Position: 50'
    Font.Charset = DEFAULT_CHARSET
    Font.Color = clWindowText
    Font.Height = -11
    Font.Name = 'MS Sans Serif'
    Font.Style = [fsBold]
    ParentFont = False
  end
  object Panel1: TPanel
    Left = 24
    Top = 24
    Width = 114
    Height = 15
    BevelKind = bkFlat
    BevelOuter = bvNone
    BevelWidth = 3
    BorderStyle = bsSizeToolWin
    ParentBackground = False
    TabOrder = 0
    object Splitter1: TSplitter
      Left = 0
      Top = 0
      Width = 50
      Height = 11
      Cursor = crDefault
      Color = clGreen
      ParentColor = False
      ResizeStyle = rsUpdate
      ExplicitLeft = -16
    end
    object Slider: TSplitter
      Left = 50
      Top = 0
      Width = 10
      Height = 11
      Cursor = crHandPoint
      Hint = 'Move Slider Left Or Right While Holding Your Mouse Button Down'
      Beveled = True
      Color = 16744448
      MinSize = 0
      ParentColor = False
      ResizeStyle = rsUpdate
      ExplicitLeft = 174
      ExplicitHeight = 20
    end
  end
  object ProgressBar1: TProgressBar
    Left = 0
    Top = 0
    Width = 281
    Height = 17
    Align = alTop
    Position = 50
    TabOrder = 1
  end
  object ProgressBar2: TProgressBar
    Left = 0
    Top = 17
    Width = 17
    Height = 118
    Align = alLeft
    Orientation = pbVertical
    Position = 50
    TabOrder = 2
  end
  object StatusBar1: TStatusBar
    Left = 0
    Top = 135
    Width = 281
    Height = 19
    Panels = <>
    SimplePanel = True
    SimpleText = 'Position: 50'
  end
end
EndDialog>Dialog1

Show>Dialog1

AddDialogHandler>Dialog1,,OnClose,Exit

//Edit the Panel1 Width to increase or decrease
//the maximum slider position. 114=100
SetDialogProperty>Dialog1,Panel1,Width,114
gosub>Start

SRT>Start

SkipLabel>DisplayLoop

Label>DisplayLoop
wait>.01
//Get Slider position
GetDialogProperty>Dialog1,Slider,Left,SliderPosition

//Display slider position in a Label
SetDialogProperty>Dialog1,SliderDisplayLabel,Caption,Position: %SliderPosition%

//Display slider position in Horizontal Progress Bar
SetDialogProperty>Dialog1,ProgressBar1,Position,%SliderPosition%

//Display slider position in Vertical Progress Bar
SetDialogProperty>Dialog1,ProgressBar2,Position,%SliderPosition%

//Display slider position in the Status Bar
SetDialogProperty>Dialog1,StatusBar1,SimpleText,Position: %SliderPosition%
goto>DisplayLoop

END>Start


srt>Exit
exit>0
END>Exit

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