Posts: 1,006
Threads: 330
Joined: Mar 2007
Hi,
I thought this might have been answered before but couldn't find it.....(sorry if I missed it). Anyway, is there an easy way to add the timeout ability (countdown timer) on a user-created dialog box similar to the example below (for MES)?
MES m
m.style="YNCn"
m.x=100
m.y=1
m.timeout=15
m.default='C'
int i=mes("message" "title" m)
Thanks so much,
Stuart
Posts: 12,087
Threads: 142
Joined: Dec 2002
Function Dialog58
;\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Edit 0x54000800 0x0 10 112 34 10 "tim"
;4 Static 0x54000000 0x0 10 122 94 10 "Click to stop the countdown."
;END DIALOG
;DIALOG EDITOR: "" 0x2030000 "" "" ""
ret
;messages
sel message
,case WM_INITDIALOG
,SetTimer hDlg 1 1000 0
,
,case WM_TIMER
,int t=GetDlgItemInt(hDlg 3 0 0)
,t-1; if(t<=0) clo hDlg; ret
,SetDlgItemInt(hDlg 3 t 0)
,
,case WM_SETCURSOR
,if(lParam>>16=WM_LBUTTONDOWN) KillTimer hDlg 1
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
Macro
str controls = "3"
str e3tim
e3tim=5 ;;time
if(!ShowDialog("Dialog58" &Dialog58 &controls)) ret
Posts: 8
Threads: 2
Joined: Nov 2013
HI,
Can you post a simple dialog box with with just the countdown timer that runs a function when the countdown gets to 0.
Posts: 12,087
Threads: 142
Joined: Dec 2002
03-11-2019, 08:03 PM
(This post was last modified: 03-11-2019, 08:04 PM by Gintaras.)
This function does it. Runs function clo. Replace the clo hDlg with your function call. Maybe remove case WM_SETCURSOR and next line.
Posts: 8
Threads: 2
Joined: Nov 2013
It runs clo hDlg repeatedly after countdown, how to do it once and show message "time Expired" in dialog?
Also need separate function to manually add more time to countdown..
thanks for your quick help with this so far!!
Posts: 12,087
Threads: 142
Joined: Dec 2002
Macro Macro300
str dd=
;BEGIN DIALOG
;0 "" 0x90C80A44 0x100 0 0 223 135 "Dialog"
;1 Button 0x54030001 0x4 120 116 48 14 "OK"
;2 Button 0x54030000 0x4 170 116 48 14 "Cancel"
;3 Static 0x54000000 0x0 8 108 48 10 ""
;4 Static 0x54000000 0x0 8 120 106 10 ""
;5 Button 0x54032000 0x0 120 96 96 14 "Set timer again"
;END DIALOG
;DIALOG EDITOR: "" 0x2040800 "" "" "" ""
int timerSeconds=5
if(!ShowDialog(dd &sub.DlgProc 0)) ret
#sub DlgProc v
function# hDlg message wParam lParam
sel message
,case WM_INITDIALOG
,sub.SetTimer hDlg timerSeconds
,
,case WM_TIMER
,timerSeconds-1
,if timerSeconds>0
,,SetDlgItemText hDlg 3 F"{timerSeconds}"
,else
,,sub.SetTimer hDlg 0
,,clo hDlg ;;or replace this code with your code
,
,case WM_SETCURSOR
,if(lParam>>16=WM_LBUTTONDOWN) KillTimer hDlg 1 ;;remove this if don't need to stop timer on click
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 5 ;;Set timer again
,timerSeconds=10
,sub.SetTimer hDlg timerSeconds
,
,case IDOK
,case IDCANCEL
ret 1
#sub SetTimer
function hDlg seconds
;If seconds>0, sets timer. Else stops timer.
if seconds>0
,SetTimer hDlg 1 1000 0
,SetDlgItemText hDlg 3 F"{seconds}"
,SetDlgItemText hDlg 4 "Click to stop the countdown."
else
,KillTimer hDlg 1
,SetDlgItemText hDlg 3 ""
,SetDlgItemText hDlg 4 "Time expired."
Posts: 726
Threads: 99
Joined: Mar 2018
03-12-2019, 08:11 AM
(This post was last modified: 03-12-2019, 08:24 AM by win.)
I have a suggestion to add a countdown parameter to the messagebox, dialog etc control function, which is sometimes useful.
Many process automation software message boxes have countdown parameters
Below is the code without the countdown parameter, which is a bit of a hassle.
Macro Macro7
str s="hello world"
MES m
m.style="O";;style is ok button only see qm help for more info
m.timeout=5;;close after 5 seconds
m.default='O';;ok button is default
mes(s "TV" m)
Posts: 12,087
Threads: 142
Joined: Dec 2002
03-12-2019, 08:17 AM
(This post was last modified: 03-12-2019, 08:19 AM by Gintaras.)
QM2:
MES m.timeout=5; mes("text" "" m)
QM3:
AuDialog.ShowEx("text", secondsTimeout: 5);
Posts: 726
Threads: 99
Joined: Mar 2018
It seems that QM3 is easier to understand.
In which month is it released?
Posts: 12,087
Threads: 142
Joined: Dec 2002
Posts: 726
Threads: 99
Joined: Mar 2018
I suggest that the main development direction of QM3 is robotic process automation, which is very promising. QM has many years of development experience.
So far, I still think that QM2 is the most powerful process automation software, it is easier to use than the RPA software of other companies in the world, for example, uipath, winautomation, etc.
|