Progress Bar Question

Technical support and scripting issues

Moderators: JRL, Dorian (MJT support)

Post Reply
fthomas
Pro Scripter
Posts: 91
Joined: Fri Oct 03, 2008 6:40 pm

Progress Bar Question

Post by fthomas » Fri Nov 12, 2010 1:07 am

Good day all. I figured out the progress bar, very good indeed!!!

Overall, the updates in 12 for the dialog box creation is 100x's better. Well worth it alone for the upgrade.

But I do have a question in regards to the progress bar. Is there any way to create a dialog box with a progress bar, that stays open, but has a cancel button. I can see if I don't try to get a result from a dialog, the script happily continues on, but how can I capture that Cancel button later in the script to stop the script from running?

Frank

fthomas
Pro Scripter
Posts: 91
Joined: Fri Oct 03, 2008 6:40 pm

Post by fthomas » Fri Nov 12, 2010 6:37 am

No worries, figured it out!

Frank

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

Post by JRL » Fri Nov 12, 2010 6:51 am

I think you're looking for the AddDialogHandler> function.

Following is a non modal dialog with a progress bar

Code: Select all

Dialog>Dialog1
object Dialog1: TForm
  Left = 339
  Top = 149
  HelpContext = 5000
  BorderIcons = [biSystemMenu]
  Caption = 'CustomDialog'
  ClientHeight = 223
  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 MSButton1: tMSButton
    Left = 181
    Top = 103
    Width = 75
    Height = 25
    Caption = 'Cancel'
    DoubleBuffered = True
    ModalResult = 2
    ParentDoubleBuffered = False
    TabOrder = 0
    DoBrowse = False
    BrowseStyle = fbOpen
  end
  object ProgressBar1: TProgressBar
    Left = 22
    Top = 20
    Width = 395
    Height = 16
    MarqueeInterval = 5
    Step = 5
    TabOrder = 9
  end
end
EndDialog>Dialog1

AddDialogHandler>Dialog1,msButton1,OnClick,Quit
Show>dialog1
Let>kk=0

Label>Loop
  Wait>0.05
  If>kk=100
    Let>value=-1
  EndIf
  If>kk=0
    Let>value=1
  EndIf
  Add>kk,%value%
  SetDialogProperty>Dialog1,ProgressBar1,Position,%kk%
Goto>Loop

SRT>Quit
  Exit>0
END>Quit

fthomas
Pro Scripter
Posts: 91
Joined: Fri Oct 03, 2008 6:40 pm

Post by fthomas » Fri Nov 12, 2010 2:26 pm

Thanks JRL, I did find that too, but I do appreciate your input.

Frank

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

Post by Phil Pendlebury » Wed Nov 17, 2010 12:18 pm

There's also a demo I did on progress bars here:

http://www.mjtnet.com/forum/viewtopic.php?t=6187

:)
Phil Pendlebury - Linktree

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