The
VCL timer component reports this message whenever anything goes wrong
with a timer
regardless of the nature of the problem: if you have the
VCL source then
look at the function TTimer.UpdateTimer. The timer has a private field
FWindowHandle which is a
handle to the window
used to
handle the timer messages. Whenever UpdateTimer is called (i.e
whenever the timer is enabled or its update rate is changed) UpdateTimer
calls Windows.SetTimer(FWindowHandle, etc.... ) if this
call fails then you will get a 'Too Many Timers' error regardless of the
actual cause of the error. This is a somewhat liberal assumption.
When a colleague of mine had the same problem as yours (random and
seemingly illogical occurances of 'Too many timers'), we replaced the timer
with a modified version of the std TTimer which called GetLastError after
SetTimer in TTimer.UpdateTimer. Not surprisingly, the error returned was
'Invalid Window
Handle'. Eventually the problem turned out to be corruption
of the Timer's window
handle (FWindowHandle) by a memory overwriting bug. I
think I would be tempted to put a MemoryChanged breakpoint on FWindowHandle
to start with.
Happy Hunting.
Martin Lafferty