Chrono qui compte trop vite!
Publié : mar. 30/oct./2007 19:53
Bonsoir a tous!
Voila un essai de chronometre (qui biensur ne fonctionne pas!)
Je poste le code car je ne trouve pas la cause du probleme...
Je me doute bien que ca va vous paraitre tout bete a resoudre, donc si vous pouviez m'expliquer, je vous serais reconnaissant!
Merci d'avance
Voila un essai de chronometre (qui biensur ne fonctionne pas!)
Je poste le code car je ne trouve pas la cause du probleme...
Code : Tout sélectionner
Enumeration
#Window_0
EndEnumeration
;- Gadget Constants
;
Enumeration
#String_0
#String_1
#String_2
#String_3
#Button_0
#Button_1
#Button_2
EndEnumeration
Procedure Open_Window_0()
If OpenWindow(#Window_0, 467, 200, 300, 150, "Chronometre", #PB_Window_SystemMenu | #PB_Window_SizeGadget | #PB_Window_TitleBar )
If CreateGadgetList(WindowID(#Window_0))
StringGadget(#String_0, 10, 20, 70, 70, "")
StringGadget(#String_1, 90, 20, 70, 70, "")
StringGadget(#String_2, 170, 20, 70, 70, "")
StringGadget(#String_3, 250, 50, 40, 40, "", #PB_String_ReadOnly | #PB_String_Numeric)
ButtonGadget(#Button_0, 10, 100, 70, 30, "")
ButtonGadget(#Button_1, 90, 100, 70, 30, "")
ButtonGadget(#Button_2, 170, 100, 70, 30, "")
EndIf
EndIf
EndProcedure
temps_de_ref = ElapsedMilliseconds()
ms = 0
s = 0
m = 0
h = 0
open_window_0()
Repeat
evenement = WindowEvent()
ms = ElapsedMilliseconds() - temps_de_ref
If ms > 999
ms = 0
s = s + 1
EndIf
If s > 59
s = 0
m = m + 1
EndIf
If m > 59
m = 0
h = h + 1
EndIf
If h > 24
h = 0
EndIf
SetGadgetText(#String_0,Str(h))
SetGadgetText(#String_1,Str(m))
SetGadgetText(#String_2,Str(s))
SetGadgetText(#String_3,Str(ms))
If evenement = #PB_Event_CloseWindow
Break
EndIf
ForEver
Merci d'avance
