Peg Timers
PEG timers provide a simple means for you to receive periodic timer messages in your
windows or controls. Any object derived from a PEG object can start any number of
individual timers. When the timer expires, that object will receive a PM_TIMER message
from PEG. The message iData member will contain the ID of the timer that expired. If
the timer is started with a non-zero reset value, the timer will automatically load itself
with the reset value and begin a new timeout.
PEG timers are maintained by PegMessageQueue. In order for PEG timers to function,
your system software must call the PegMessageQueue member function TimerTick
periodically to indicate to PEG that one tick time has expired. Timers are created and
destroyed with the following functions:
inline void SetTimer(WORD wId, LONG lCount, LONG lReset)
inline void KillTimer(WORD wId)
You start a PegTimer by calling the PegMessageQueue member function SetTimer().
The parameters allow you to specify a timer Id value, the first timeout period, and
successive timeout periods. The timer Id value can be any number greater than zero. If
you have one window or control that creates many timers, you will probably want to
assign them unique Id values so that you can recognize each timer expiration message.
While you have an active timer running, you will receive a PM_TIMER message in your
Message() handling function each time the timer expires. When you want to stop a timer,
you use the PegMessageQueue member function KillTimer(). If you pass an Id value of
zero to the KillTimer function, all timers owned by the calling object are deleted.
For more information on messages, refer to the example add-in DebugExample. This
add-in outputs the names of the messages that get sent to the MessageQueue on the
ClassPad. It is a very useful add-in to help you understand when message are sent, and in
what order they are sent.
30