Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
timeout for dialogs like in mes and input boxes
#6
Macro Macro300
Code:
Copy      Help
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."


Messages In This Thread

Forum Jump:


Users browsing this thread: 1 Guest(s)