Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
wait with dialog
#1
Is it possible to use wait in conjunction with a dialog box? What I'd like to do is offer a dialog box to the user for some input, but if the users does not submit the input within 30 sec, close the box. Ideally it would be best to know nothing was submitted so default settings could be set automatically, but I can preset the defaults before offering the dialog so that's not really important.

at the moment there is this line of code which works fine, but waits until 'OK' or 'Cancel' is pressed to continue the script.

if(!ShowDialog(dd 0 &controls)) ret

Thanks for any help.
#2
I poked around and seems the only way to manage a timeout on a dialog box is to edit a system function which is not allowed. Any other ideas?
#3
Function Dialog64
Code:
Copy      Help
str dd=
;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 224 136 "Dialog"
;100 Static 0x54000000 0x0 8 100 208 13 ""
;1 Button 0x54030001 0x4 116 116 48 14 "OK"
;2 Button 0x54030000 0x4 168 116 48 14 "Cancel"
;END DIALOG
;DIALOG EDITOR: "" 0x2040700 "*" "" "" ""

sel ShowDialog(dd &sub.DlgProc 0)
,case IDOK out "OK"
,case 12345 out "timeout"
,case else ret ;;Cancel


#sub DlgProc
function# hDlg message wParam lParam

int-- t_time

sel message
,case WM_INITDIALOG
,t_time=10 ;;edit this if need
,SetTimer hDlg 1 1000 0
,
,case WM_TIMER
,sel wParam
,,case 1
,,t_time-1
,,if(t_time=0) DT_Ok hDlg 12345
,,else SetDlgItemText hDlg 100 F"Will close after {t_time} s. Click here to stop the timer."
,
,case [WM_LBUTTONDOWN,WM_NCLBUTTONDOWN] ;;clicked a non-control part of the dialog
,KillTimer hDlg 1
,
,case WM_DESTROY
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case IDOK
,case IDCANCEL
ret 1
#4
Thanks Gintaras works perfectly, but I do have one question. Is there a way to distinguish between 'cancel' and timeout? I'd like both these options to have a different meaning in the macro. Timeout jump to some default routine and cancel would end the macro.

Jim
#5
Code updated.


Forum Jump:


Users browsing this thread: 2 Guest(s)