PlanetSquires Forums

Support Forums => General Board => Topic started by: Rolf Brandt on May 29, 2014, 01:32:32 PM

Title: Timer Functions
Post by: Rolf Brandt on May 29, 2014, 01:32:32 PM
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)


Title: Re: Timer Functions
Post by: Jim Dunn on May 30, 2014, 11:07:33 AM
Rolf, once again, you're such a generous person, we appreciate it!!!
Title: Re: Timer Functions
Post by: Pedro Marquez on May 30, 2014, 03:07:04 PM
It is appreciated, thanks.
Title: Re: Timer Functions
Post by: Petrus Vorster on May 31, 2014, 06:40:07 AM
Thanks Rolf

Very kind to share!
Title: Re: Timer Functions
Post by: John Montenigro on June 04, 2014, 12:19:33 AM
Thanks, Rolf!
-John