Closing Dialogs With Progress Bar

Technical support and scripting issues

Moderators: Dorian (MJT support), JRL

Post Reply
MadQuestion
Pro Scripter
Posts: 70
Joined: Wed Nov 08, 2017 6:54 pm

Closing Dialogs With Progress Bar

Post by MadQuestion » Wed Nov 15, 2017 12:21 am

I am trying to close a dialog upon completing the position of the progress bar.
Below is the sample code how would I edit this exact code to close dialog1 once the progress bar is full without having to click a modal button? Any suggestions are welcome. :D :) :(

Code: Select all


Dialog>Dialog1
object Dialog1: TForm
  Left = 576
  Top = 266
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'Progress Bar Example'
  ClientHeight = 116
  ClientWidth = 439
  Color = clBtnFace
  Font.Charset = DEFAULT_CHARSET
  Font.Color = clWindowText
  Font.Height = -11
  Font.Name = 'MS Sans Serif'
  Font.Style = []
  OldCreateOrder = True
  ShowHint = True
  OnTaskBar = False
  PixelsPerInch = 96
  TextHeight = 13
  object ProgressBar1: TProgressBar
    Left = 18
    Top = 17
    Width = 399
    Height = 17
    TabOrder = 8
  end
  object btnStart: tMSButton
    Left = 24
    Top = 56
    Width = 75
    Height = 25
    Caption = 'Start'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 9
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object btnStop: tMSButton
    Left = 128
    Top = 56
    Width = 75
    Height = 25
    Caption = 'Stop'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 10
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object btnReset: tMSButton
    Left = 232
    Top = 56
    Width = 75
    Height = 25
    Caption = 'Reset'
    DoubleBuffered = True
    ParentDoubleBuffered = False
    TabOrder = 11
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object btnClose: tMSButton
    Left = 344
    Top = 56
    Width = 75
    Height = 25
    Caption = 'Close'
    DoubleBuffered = True
    ModalResult = 2
    ParentDoubleBuffered = False
    TabOrder = 12
    DoBrowse = False
    BrowseStyle = fbOpen
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,btnStart,OnClick,DoProgress
AddDialogHandler>Dialog1,btnStop,OnClick,DoStop
AddDialogHandler>Dialog1,btnReset,OnClick,DoReset
AddDialogHandler>Dialog1,btnClose,OnClick,DoClose

GetDialogProperty>Dialog1,ProgressBar1,Min,intMin
GetDialogProperty>Dialog1,ProgressBar1,Max,intMax
Let>LOADINGPOS=intMin
Let>ProgressFlag=0

Show>Dialog1,res1
MessageModal>WAITING FOR NEXT DIALOG TO OPEN

SRT>DoProgress
  SetDialogProperty>Dialog1,btnStart,Enabled,False
  If>ProgressFlag=0
    Let>LOADINGPOS=intMin
  EndIf
  Repeat>LOADINGPOS
    Let>LOADINGPOS=LOADINGPOS+10
    SetDialogProperty>Dialog1,ProgressBar1,Position,LOADINGPOS
    If>ProgressFlag>1
      Goto>EndProgress
    EndIf
    Wait>0.05
  Until>LOADINGPOS=intMax
  Label>EndProgress
  SetDialogProperty>Dialog1,btnStart,Enabled,True
  Let>ModalResult=2
END>DoProgress

SRT>DoReset
  Let>LOADINGPOS=intMin
  SetDialogProperty>Dialog1,ProgressBar1,Position,LOADINGPOS
END>DoReset

SRT>DoStop
  Let>ProgressFlag=2
  SetDialogProperty>Dialog1,ProgressBar1,Position,LOADINGPOS
END>DoStop

SRT>DoClose
  Let>LOADINGPOS=intMax
END>DoClose


User avatar
JRL
Automation Wizard
Posts: 3497
Joined: Mon Jan 10, 2005 6:22 pm
Location: Iowa

Re: Closing Dialogs With Progress Bar

Post by JRL » Wed Nov 15, 2017 2:30 am

Just add CloseDialog>Dialog1 to the end of your DoProgress subroutine.

Code: Select all

SRT>DoProgress
  SetDialogProperty>Dialog1,btnStart,Enabled,False
  If>ProgressFlag=0
    Let>LOADINGPOS=intMin
  EndIf
  Repeat>LOADINGPOS
    Let>LOADINGPOS=LOADINGPOS+10
    SetDialogProperty>Dialog1,ProgressBar1,Position,LOADINGPOS
    If>ProgressFlag>1
      Goto>EndProgress
    EndIf
    Wait>0.05
  Until>LOADINGPOS=intMax
  Label>EndProgress
  SetDialogProperty>Dialog1,btnStart,Enabled,True
  Let>ModalResult=2
  CloseDialog>Dialog1
END>DoProgress

MadQuestion
Pro Scripter
Posts: 70
Joined: Wed Nov 08, 2017 6:54 pm

Re: Closing Dialogs With Progress Bar

Post by MadQuestion » Wed Nov 15, 2017 3:25 pm

I must of been putting my CloseDialog>Dialog1 on the wrong line or something. Thanks for the help

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