Timers
Publié : jeu. 06/oct./2011 9:48
Malgré mes recherches je ne trouve pas le tuto sur les timers, existe-t-il toujours sur ce forum ?
Merci.
Merci.
Code : Tout sélectionner
; Création de la fenêtre et de la GadgetList
Procedure Timer(hwnd.l, uMsg.l, idEvent.l, dwTime.l)
Select uMsg
Case #WM_TIMER
PostMessage_(hwnd, #WM_USER, idEvent, dwTime)
EndSelect
EndProcedure
If OpenWindow(0, 0, 0, 200, 240, "Test", #PB_Window_SystemMenu | #PB_Window_ScreenCentered | #PB_Window_MinimizeGadget) = 0 Or CreateGadgetList(WindowID(0)) = 0
End
EndIf
ButtonGadget(0, 0, 0, 200, 20, "Lancer")
ButtonGadget(1, 0, 20, 200, 20, "Arrêter")
DisableGadget(1, 1)
ListViewGadget(2, 0, 40, 200, 200)
Repeat
Event = WindowEvent()
Select Event
Case#PB_Event_Gadget
Select EventGadget() ; Gadgets
Case 0
SetTimer_(WindowID(0), 1, 1000 * 5, @Timer())
SetTimer_(WindowID(0), 2, 1000 * 3, @Timer())
DisableGadget(0, 1)
DisableGadget(1, 0)
Debug "Activer"
Case 1
KillTimer_(WindowID(0), 10)
KillTimer_(WindowID(0), 20)
DisableGadget(0, 0)
DisableGadget(1, 1)
Debug "Désactiver"
EndSelect
Case #WM_USER
Heure.s = FormatDate("%hh:%ii:%ss", Date())
AddGadgetItem(2, -1, "Timer " + Str(EventwParam()) + " - " + Heure)
EndSelect
Until Event = #PB_Event_CloseWindow
KillTimer_(WindowID(0), 1)
KillTimer_(WindowID(0), 2)
End