I just needed to update an older program with some functionality to change timer intervals during runtime. Since PowerBasic does not have any special functions for it I wrote one.
Maybe it is helpful for someone else. There is also a little demo project attached to demonstrate the use of it.
[Edit: 2014-05-29 18:14]
I added also Timerfunctions.zip. It contains a folder which you can place in FF3's codestore so that you have the functions on hand with F8.
Rolf
'timerfunctions.inc
'--------------------------------------------------------------------------------
' CreateOrChangeTimer
' Create a timer or change it's interval
'--------------------------------------------------------------------------------
Function CreateOrChangeTimer(ParentForm As Dword, _
TimerHwnd As Dword, _
TimerIdc As Dword, _
NewInterval As Long _
) As Long
KillTimer ParentForm, TimerIdc
TimerHwnd = SetTimer(ParentForm, TimerIdc, NewInterval, ByVal %Null)
End Function
'--------------------------------------------------------------------------------
' DisableTimer
' Disable (kill) a timer
'--------------------------------------------------------------------------------
Function DisableTimer(ParentForm As Dword, _
TimerIdc As Dword _
) As Long
KillTimer ParentForm, TimerIdc
End Function
'Usage
'Change interval of an existing timer or recreate the timeer
CreateOrChangeTimer(HWND_FORM1,HWND_FORM1_TIMER1,IDC_FORM1_TIMER1,500)
'Disable the timer (in reality kill it)
DisableTimer(HWND_FORM1, IDC_FORM1_TIMER1)
'...and enable it again (recreate it)
CreateOrChangeTimer(HWND_FORM1,HWND_FORM1_TIMER1,IDC_FORM1_TIMER1,2000)
Rolf, once again, you're such a generous person, we appreciate it!!!
It is appreciated, thanks.
Thanks Rolf
Very kind to share!
Thanks, Rolf!
-John