Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
dialog cancel with timing code
#1
i have a dialog that starts a timer when a button is pushed but i cant hit the cancel button till the time is up. is there a way to do this?

thanks
#2
EnableWindow(id(IDCANCEL hDlg) 0)
SetTimer ...
...
case WM_TIMER
EnableWindow(id(IDCANCEL hDlg) 1)
#3
i cant seem to make this work.
what am i doing wrong? im tring to do a 3 second pause before the "bee" as a test.

Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str a
if(!ShowDialog("v10_2" &v10_2)) ret
;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 109 17 "10+2"
;3 Button 0x54032001 0x4 2 2 48 14 "Start 10+2"
;2 Button 0x54030000 0x4 56 2 48 14 "End 10+2"
;END DIALOG
;DIALOG EDITOR: "" 0x2010703 "" ""


ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,a="10 minutes"
,EnableWindow(id(IDCANCEL hDlg) 0)
,a.setwintext(win("10+2"))
,SetTimer hDlg 0 3000 0
,bee
,case WM_TIMER
,EnableWindow(id(IDCANCEL hDlg) 1)
,case IDCANCEL DT_Cancel hDlg
ret 1
#4
WM_TIMER is separate message, not part of WM_COMMAND

Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str a
if(!ShowDialog("v10_2" &v10_2)) ret
;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 109 17 "10+2"
;3 Button 0x54032001 0x4 2 2 48 14 "Start 10+2"
;2 Button 0x54030000 0x4 56 2 48 14 "End 10+2"
;END DIALOG
;DIALOG EDITOR: "" 0x2010703 "" ""


ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
,case WM_TIMER
,if(wParam=0) ;;timer id
,,KillTimer hDlg wParam
,,EnableWindow(id(IDCANCEL hDlg) 1)
,,bee
ret
;messages2
sel wParam
,case 3
,a="10 minutes"
,EnableWindow(id(IDCANCEL hDlg) 0)
,a.setwintext(hDlg)
,SetTimer hDlg 0 3000 0
,case IDCANCEL DT_Cancel hDlg
ret 1
#5
Ahhh...got it.

but when i put in "bee" after the SetTimer it goes off immediately rather than 3 seconds later do i have the wrong parameter set?

SetTimer hDlg 0 3000 0
#6
SetTimer is not a wait function. Maybe this is what you need:

Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str a
if(!ShowDialog("v10_2" &v10_2)) ret
;BEGIN DIALOG
;0 "" 0x10C80A44 0x100 0 0 109 17 "10+2"
;3 Button 0x54032001 0x4 2 2 48 14 "Start 10+2"
;2 Button 0x54030000 0x4 56 2 48 14 "End 10+2"
;END DIALOG
;DIALOG EDITOR: "" 0x2010703 "" ""


ret
;messages
sel message
,case WM_INITDIALOG DT_Init(hDlg lParam); ret 1
,case WM_DESTROY DT_DeleteData(hDlg)
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 3
,a="10 minutes"
,a.setwintext(hDlg)
,EnableWindow(id(IDCANCEL hDlg) 0)
,opt waitmsg 2
,wait 3
,EnableWindow(id(IDCANCEL hDlg) 1)
,bee

,case IDCANCEL DT_Cancel hDlg
ret 1
#7
works great!

thanks.


Forum Jump:


Users browsing this thread: 1 Guest(s)