Hi All,
I need to use at least 3 timers to do a variety of different stuff in a program, I'm wondering if this below method is okay, am I doing correctly ?
I need to use at least 3 timers to do a variety of different stuff in a program, I'm wondering if this below method is okay, am I doing correctly ?
Code:
' Multiple Timers.bas #COMPILE EXE #DIM ALL #INCLUDE "Win32Api.inc" %IDC_ATimer = 101 %IDC_BTimer = 102 %IDC_CTimer = 103 %IDC_GDisplay = 105 ' handles for timers GLOBAL hAtim , hBtim , hCtim AS DWORD FUNCTION PBMAIN () AS LONG LOCAL hSpin AS DWORD DIALOG NEW PIXELS, 0 , "My Dialog", 100 ,50 , 300, 300,_ %WS_SYSMENU, %WS_EX_TRANSPARENT TO hSpin CONTROL ADD GRAPHIC, hSpin, %IDC_GDisplay, "", _ 10, 10, 150, 150 DIALOG SHOW MODAL hSpin, CALL DlgSpProc() END FUNCTION CALLBACK FUNCTION DlgSpProc() AS LONG SELECT CASE CB.MSG CASE %WM_INITDIALOG ' setup the timers hAtim = settimer(CB.HNDL, %IDC_ATimer, 15, 0) hBtim = settimer(CB.HNDL, %IDC_BTimer, 150, 0) hCtim = settimer(CB.HNDL, %IDC_CTimer, 200, 0) CASE %WM_TIMER IF hAtim THEN ' Do stuff A --- this is a ONE time process -- after this we kill the associated timer killtimer(CB.HNDL, %IDC_ATimer) hATim = 0 END IF IF hBtim THEN ' Do stuff B END IF IF hCtim THEN ' Do stuff C END IF CASE %WM_DESTROY ' clean up the timers IF hATim THEN killtimer(CB.HNDL, %IDC_ATimer) hATim = 0 END IF IF hBTim THEN killtimer(CB.HNDL, %IDC_BTimer) hBTim = 0 END IF IF hCTim THEN killtimer(CB.HNDL, %IDC_CTimer) hCTim = 0 END IF END SELECT END FUNCTION
Comment