PlanetSquires Forums

Support Forums => Other Software and Code => Topic started by: Stephane Fonteyne on September 24, 2013, 04:46:32 AM

Title: Timers don't stop with counting if load the FF Main Form Why?
Post by: Stephane Fonteyne on September 24, 2013, 04:46:32 AM
Dear support,

I try to stop (kill) the timers when I loading the form but not succes. I put the code from kill the timers in the WM_DESTROY clausule.

Have someone an solution for this problem

I attach the code in zip format. Its an FF3 project
Title: Re: Timers don't stop with counting if load the FF Main Form Why?
Post by: Paul Squires on September 24, 2013, 08:43:47 AM
You can not KillTimer in the WM_CREATE because the timers do not exist at that point. In the FireFly code generation, the Timers are not created until after  the WM_CREATE is called. I will take a look at your project and suggest a way to stop your timers from firing. I assume a global flag variable in the WM_TIMER code that will signal the timer to fire will do the trick.

I will get back to you on this one.
Title: Re: Timers don't stop with counting if load the FF Main Form Why?
Post by: Paul Squires on September 24, 2013, 03:21:27 PM
You have 3 timers. To prevent the timers from firing when the form loads follow this advice:

(1)  Create 3 global variables.
      Global gStartTimer1 As Long
      Global gStartTimer2 As Long
      Global gStartTimer3 As Long

(2)  For each of the three WM_TIMER timer handlers place a line of code like:

'--------------------------------------------------------------------------------
Function FORM1_TIMER1_WM_TIMER ( _
                               hWndForm      As Dword, _  ' handle of Form
                               wTimerID      As Dword  _  ' the timer identifier
                               ) As Long
    If gStartTimer1 = %FALSE Then Exit Function


(3)  When you want to enable the timer to start firing then simply set the appropriate global variable:
       gStartTimer1 = %TRUE
       etc....
      Put that code in your handlers like FORM1_BTNSTART_BN_CLICKED, etc.