I found this source code in my PB folders. It was written by Danilo, I searched the PureBasic Forum, but couldn't locate it, so I'm including it here. It shows 2 timers in use at one time.
Code: Select all
;-------------------------------------------------
; Another great little demo from Danilo on timers
; and scrolling.
;-------------------------------------------------
Global myText$
Global hWnd.l
Global TextLength.l
#ScrollSpeed_in_Milliseconds = 70
myText$ = " This is a little Scroller-Test with the Timer by Danilo "
TextLength = Len(myText$)
Procedure Scroller()
;Shared Scroller_a
Shared Scroller_Position
Shared Scroller_Direction
If Scroller_Position < TextLength + 1 And Scroller_Direction = 0
TEMP$ = Right(myText$,Scroller_Position)
SetWindowText_(hWnd, TEMP$)
Scroller_Position+1
Else
Scroller_Direction = 1
TEMP$ = Right(myText$,Scroller_Position)
SetWindowText_(hWnd, TEMP$)
Scroller_Position-1
If Scroller_Position = 0 : Scroller_Direction = 0 : EndIf
EndIf
EndProcedure
Procedure mybeep()
beep_(500,1000)
EndTimer(0)
DisableGadget(0,0)
DisableGadget(1,0)
StartTimer(1, #ScrollSpeed_in_Milliseconds, @Scroller())
EndProcedure
Procedure Alarm()
beep_(500,60)
EndProcedure
MessageRequester("Minimal Timer Resolution",Str(GetMinTimerResolution()),0)
MessageRequester("Maximal Timer Resolution",Str(GetMaxTimerResolution()),0)
hWnd = OpenWindow(0, (GetSystemMetrics_(#SM_CXSCREEN)-400)/2,(GetSystemMetrics_(#SM_CYSCREEN)-100)/2, 400, 100, #PB_Window_SystemMenu,"")
If CreateGadgetList(WindowID())
ButtonGadget(0, 10, 10, 100, 25, "Quit Scroller")
DisableGadget(0,1)
ButtonGadget(1, 120, 10, 250, 25, "Change Timer from Scroller to Beep")
DisableGadget(1,1)
EndIf
SetForeGroundWindow_(hWnd)
StartTimer(0,1000, @mybeep())
;message loop
Repeat
EventID.l=WaitWindowEvent()
If EventID = #PB_EventGadget
Select EventGadgetID()
Case 0 ; End the Timer
A$ = GetGadgetText(0)
If A$ = "Quit Alarm"
SetGadgetText(0,"Exit Program")
DisableGadget(1,1)
EndIf
If A$ = "Exit Program"
Quit = 1
EndIf
EndTimer(1)
Case 1
SetGadgetText(0,"Quit Alarm")
StartTimer(1, 100, @Alarm())
EndSelect
EndIf
; pressed CloseButton or ALT+F4 ??
If EventID = #PB_EventCloseWindow
Quit = 1
EndIf
Until Quit = 1
; the end