Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Dialog with 'for' cicle
#1
Hello there!
I have one dialog that has the option to shrink to the tray bar. What I want to do is to insert one str, and start a count down timer on my dialog while it is on the tray bar. The thing is, I'm kind of stuck because every time I make the timer run, the dialog gets stuck and stops running.

Can anyone tell me what am I doing wrong?

Thanks!!

Function gmg_reminder
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
;g10
if(hDlg) goto messages
str s1 s2
str controls = "6"
str e6

if(!ShowDialog("gmg_reminder" &gmg_reminder &controls)) ret
if(!ShowDialog("gmg_reminder" &gmg_reminder 0)) ret


;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 119 98 "GMG Reminder"
;2 Button 0x54030000 0x4 8 60 100 21 "Esconder"
;3 Button 0x54032000 0x0 8 84 100 10 "Fechar"
;4 Button 0x54032000 0x0 70 8 38 10 "Start 2h"
;5 Button 0x54032000 0x0 70 20 38 10 "Start 4h"
;6 Edit 0x54030080 0x200 10 14 40 14 ""
;7 Static 0x54000000 0x0 22 2 48 12 "Site"
;8 Static 0x54000000 0x0 12 40 48 13 "site"
;9 Static 0x54000000 0x0 66 40 48 13 "tempo"
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "*" "" "" ""

ret
;messages
sel message

,case WM_INITDIALOG
,Tray-- t_ti
,t_ti.AddIcon("" "GMG Reminder" 5 hDlg)
,;clo hDlg ;;hide
,SetTimer hDlg 1 1000 0
,goto g1
,case WM_DESTROY
,t_ti.Delete

,case WM_USER+101
,sel lParam


,,case WM_LBUTTONUP ;;on left click tray icon
,,;gMostrar
,,act hDlg; err

,,case WM_RBUTTONUP ;;on right click tray icon
,,sel ShowMenu("1 Mostrar[]2 Fechar" hDlg)
,,,case 1 goto gMostrar
,,,case 2 goto gSair


,case WM_COMMAND goto messages2

,;g1

ret
;messages2
sel wParam
,case 4: s1.getwintext(id(6 hDlg)) s1.setwintext(id(8 hDlg))
,,int i j k
,,str t2h
,,for i 1 -1 -1
,,,for j 59 -1 -1
,,,,for k 59 -1 -1
,,,,,t2h.format("%.2i:%.2i:%.2i" i j k)
,,,,,wait 1
,,,,,t2h.setwintext(id(9 hDlg))
,,,,,goto g10

,case 5: s1.getwintext(id(6 hDlg)) s1.setwintext(id(8 hDlg))
,,str t4h
,,for i 3 -1 -1
,,,for j 59 -1 -1
,,,,for k 59 -1 -1
,,,,,t2h.format("%.2i:%.2i:%.2i" i j k)
,,,,,wait 1
,,,,,t2h.setwintext(id(9 hDlg))


,case IDCANCEL ;;Hide, X
,min hDlg; hid hDlg; ret

,case 3 ;;Exit
,;gSair
,DT_Cancel hDlg
ret 1

Thanks a lot!
Pedro
#2
you have several mistakes in your dialog code that are causing your dialog to lock up in a loop
Function gmg_reminder
Code:
Copy      Help
\Dialog_Editor
function# hDlg message wParam lParam
if(hDlg) goto messages
str s1 s2
str controls = "6"
str e6

if(!ShowDialog("gmg_reminder" &gmg_reminder &controls)) ret

;BEGIN DIALOG
;0 "" 0x90C80AC8 0x0 0 0 119 98 "GMG Reminder"
;2 Button 0x54030000 0x4 8 60 100 21 "Esconder"
;3 Button 0x54032000 0x0 8 84 100 10 "Fechar"
;4 Button 0x54032000 0x0 70 8 38 10 "Start 2h"
;5 Button 0x54032000 0x0 70 20 38 10 "Start 4h"
;6 Edit 0x54030080 0x200 10 14 40 14 ""
;7 Static 0x54000000 0x0 22 2 48 12 "Site"
;8 Static 0x54000000 0x0 12 40 48 13 "site"
;9 Static 0x54000000 0x0 66 40 48 13 "tempo"
;END DIALOG
;DIALOG EDITOR: "" 0x2030408 "*" "" "" ""

ret
;messages
int-- timervar
sel message
,case WM_INITDIALOG
,Tray-- t_ti
,t_ti.AddIcon("" "GMG Reminder" 5 hDlg)
,case WM_TIMER
,if timervar<=0
,,KillTimer(hDlg 1)
,,TO_Enable(hDlg "4 5" 1)
,_s.format("%02i:%02i:%02i" timervar/3600 timervar/60%60 timervar%60)
,_s.setwintext(id(9 hDlg));err
,timervar-1
,case WM_DESTROY
,KillTimer(hDlg 1)
,t_ti.Delete
,case WM_USER+101
,sel lParam
,,case WM_LBUTTONUP ;;on left click tray icon
,,act hDlg; err
,,case WM_RBUTTONUP ;;on right click tray icon
,,sel ShowMenu("1 Mostrar[]2 Fechar" hDlg)
,,,case 1 act hDlg
,,,case 2 DT_EndDialog hDlg
,case WM_COMMAND goto messages2
ret
;messages2
sel wParam
,case 4: s1.getwintext(id(6 hDlg)) s1.setwintext(id(8 hDlg))
,timervar=7200
,SetTimer hDlg 1 1000 0
,TO_Enable(hDlg "4 5" 0)
,case 5: s1.getwintext(id(6 hDlg)) s1.setwintext(id(8 hDlg))
,timervar=14400
,SetTimer hDlg 1 1000 0
,TO_Enable(hDlg "4 5" 0)
,case IDCANCEL ;;Hide, X
,min hDlg; hid hDlg; ret
,case 3 ;;Exit
,;gSair
,DT_Cancel hDlg
ret 1
#3
It works great!

I'm going to see carefully the changes you've made to see what was wrong!
Thanks again!! Big Grin


Forum Jump:


Users browsing this thread: 1 Guest(s)