Project has a Timer with Interval that was originally set via Workspace/Properties to a value of 6000
I wanted to make a change, to ensure that the Interval would only be set via program code after some initial stuff I was doing in FRMMAIN_WM_CREATE. So to avoid having the timer fire before my initial stuff was done, I deleted the Interval value through Workspace/Properties.
I had not yet added the SetTimer statement where it needed to go, but I did run a compile.
Compilation failed, reporting a Syntax Error in line 270, which had not been edited for months and had been just fine.
(line 270) FF_Control_SetText (HWND_FRMMAIN_TXTENDYEAR, Right$(Date$, 4))
The error location was shown between "Right" and the "$"
I commented out the line, but compilation returned the same error, on the same line, at the same point! Remember, the line was now a comment!!!
Suspecting broken syntax in a different area, I re-checked the entire module. I had only made minor edits, so I reverted back to the starting version, but still got the same error.
When the only thing left that I could remember was the change to the Timer Interval, I went back to the Timer and set the Interval to 0. And now everything compiled fine!
It would appear that upon Compilation, a blank Interval on a Timer control wreaks havoc elsewhere... Leave it to me to do something dumb like that! (But it does make me wonder if it's FF's job to check for valid control values. Paul, what items get checked and which don't?)
-John
++++++
I still need to know how to prevent that timer from firing...
Should I remove the control from the Form completely, and create it dynamically with SDK code at the point I first want it to start running?
I guess I'm asking is: what benefit do I get from putting the control on the Form as opposed to creating it dynamically in SDK code? Does putting a timer on a form mean that the Interval starts counting when the form is created? How can I defer or otherwise control the timer?
++++++
-John
Quote from: John Montenigro on December 06, 2009, 10:59:45 AM
++++++
I still need to know how to prevent that timer from firing...
Does putting a timer on a form mean that the Interval starts counting when the form is created? How can I defer or otherwise control the timer?
++++++
What some people do is to create a global variable called say, gTimerFlag, and set it to %TRUE or %FALSE depending on whether you want the timer code to execute.
Global gTimerFlag As Long
'--------------------------------------------------------------------------------
Function FORM1_TIMER1_WM_TIMER ( _
hWndForm As Dword, _ ' handle of Form
wTimerID As Dword _ ' the timer identifier
) As Long
If gTimerFlag = %FALSE Then Exit Function
' Change the caption on the Form just to show that the timer is firing.
Static p As Long
Incr p
FF_Control_SetText hWndForm, Str$(p)
End Function
'--------------------------------------------------------------------------------
Function FORM1_COMMAND1_BN_CLICKED ( _
ControlIndex As Long, _ ' index in Control Array
hWndForm As Dword, _ ' handle of Form
hWndControl As Dword, _ ' handle of Control
idButtonControl As Long _ ' identifier of button
) As Long
' Toggle the timer flag
gTimerFlag = Not gTimerFlag
End Function
OK, very good! Clean and simple. Thanks!