frmMyForm = CREATEOBJECT('myTimer')
frmMyForm.SHOW
READ EVENTS
RETURN
DEFINE CLASS mytimer AS form
Top = 0
Left = 0
Closable = .f.
Height = 454
Width = 633
DoCreate = .T.
Caption = "Timer"
mduration = 120 && Duracion en segundos
mycount = 0
Name = "myTimer"
ADD OBJECT cmdexit AS commandbutton WITH ;
Top = 396, ;
Left = 120, ;
Height = 27, ;
Width = 84, ;
Caption = "\<Salir", ;
Name = "cmdExit"
ADD OBJECT command1 AS commandbutton WITH ;
Top = 396, ;
Left = 216, ;
Height = 27, ;
Width = 84, ;
Caption = "\<Iniciar", ;
Name = "Command1"
ADD OBJECT txttime AS textbox WITH ;
FontSize = 72, ;
Height = 108, ;
Left = 108, ;
Top = 36, ;
Visible = .F., ;
Width = 384, ;
BackColor = RGB(128,255,255), ;
Name = "txtTime"
ADD OBJECT timer1 AS timer WITH ;
Top = 396, ;
Left = 540, ;
Height = 23, ;
Width = 23, ;
Name = "Timer1"
PROCEDURE mytimer
LOCAL nowLeft
nowLeft = ThisForm.myCount - (HOUR(DATETIME())*3600) - ;
(MINUTE(DATETIME())*60) - SEC(DATETIME())
ThisForm.txtTime.Value = RIGHT("00"+ALLTRIM(STR(INT(nowLeft/3600))),2)+":"+ ;
RIGHT("00"+ALLTRIM(STR(INT(MOD(nowLeft,3600)/60))),2)+":"+ ;
RIGHT("00"+ALLTRIM(STR((MOD(nowLeft,60)))),2)
IF nowLeft < 1
ThisForm.txtTime.Visible = .f.
ThisForm.Timer1.Interval = 0
ThisForm.Timer1.Reset()
ENDIF
ThisForm.txtTime.Refresh()
ENDPROC
PROCEDURE cmdexit.Click
CLEAR EVENTS
ThisForm.Release()
ENDPROC
PROCEDURE command1.Click
ThisForm.myCount = (HOUR(DATETIME())*3600) + ;
(MINUTE(DATETIME())*60) + ;
SEC(DATETIME()) + (ThisForm.mDuration*60)
ThisForm.Timer1.Interval = 1000
ThisForm.Timer1.Reset()
ThisForm.txtTime.Visible = .t.
LOCAL nowLeft
nowLeft = ThisForm.mDuration*60
ThisForm.txtTime.Value = RIGHT("00"+ALLTRIM(STR(INT(nowLeft/3600))),2)+":"+ ;
RIGHT("00"+ALLTRIM(STR(INT(MOD(nowLeft,3600)/60))),2)+":"+ ;
RIGHT("00"+ALLTRIM(STR((MOD(nowLeft,60)))),2)
ThisForm.txtTime.Refresh()
ENDPROC
PROCEDURE timer1.Timer
ThisForm.myTimer()
ENDPROC
ENDDEFINE