Hints, tips and tricks for newbies
Moderators: Dorian (MJT support), JRL
-
jsmyong55
- Newbie
- Posts: 18
- Joined: Thu Aug 29, 2013 4:14 am
Post
by jsmyong55 » Sun Sep 01, 2013 3:20 am
I have created this Dialog box. Can anyone teach me how to automatically timeout and close it after say 5s? I can do it if its a Message, but not sure how to for Dialog or MessageModal.
Code: Select all
Dialog>Dialog1
object Dialog1: TForm
Left = 247
Top = 97
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Labour Scheduling Tool'
ClientHeight = 81
ClientWidth = 295
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 Label1: TLabel
Left = 16
Top = 8
Width = 3
Height = 13
end
object MSButton1: tMSButton
Left = 16
Top = 40
Width = 75
Height = 25
Caption = 'Show Log'
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 104
Top = 40
Width = 75
Height = 25
Caption = 'Show CSV'
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
[/code]
-
JRL
- Automation Wizard
- Posts: 3526
- Joined: Mon Jan 10, 2005 6:22 pm
- Location: Iowa
Post
by JRL » Sun Sep 01, 2013 4:51 am
One way to time out a dialog would be to use a non-modal dialog and create a timer in the script. When the time specified is met, the script could close the dialog. But that method won't work with modal dialogs or modal messages.
Onevent>s fire every couple of milliseconds even when there is a modal dialog or a modal message holding the script idle. A custom OnEvent> might be one way to close a modal dialog or modal message. See the example below.
Code: Select all
OnEvent>Custom,DialogTimeOut,UnusedVar,UnUsedSub
Timer>StartTime
Dialog>Dialog1
object Dialog1: TForm
Left = 247
Top = 97
HelpContext = 5000
BorderIcons = [biSystemMenu]
Caption = 'Labour Scheduling Tool'
ClientHeight = 81
ClientWidth = 295
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 Label1: TLabel
Left = 16
Top = 8
Width = 3
Height = 13
end
object MSButton1: tMSButton
Left = 16
Top = 40
Width = 75
Height = 25
Caption = 'Show Log'
TabOrder = 0
DoBrowse = False
BrowseStyle = fbOpen
end
object MSButton2: tMSButton
Left = 104
Top = 40
Width = 75
Height = 25
Caption = 'Show CSV'
TabOrder = 1
DoBrowse = False
BrowseStyle = fbOpen
end
end
EndDialog>Dialog1
Show>Dialog1,res1
SRT>DialogTimeOut
Timer>TestTime
If>{%TestTime%-%StartTime%>5000}
IfWindowOpen>Labour Scheduling Tool
CloseDialog>Dialog1
EndIf
IfWindowOpen>Macro Scheduler Message
CloseWindow>Macro Scheduler Message
EndIf
EndIf
END>DialogTimeOut
Timer>StartTime
MessageModal>This modal message will self destruct in 5 seconds
-
jsmyong55
- Newbie
- Posts: 18
- Joined: Thu Aug 29, 2013 4:14 am
Post
by jsmyong55 » Sun Sep 01, 2013 2:11 pm
Worked like a charm. Thanks JRL. Repped.