With this class you can create a timer. This timer sends a timer message when a specific amount of time has passed. After the timer has started, you will receive a message telling you that the time has ellapsed. You will continue to receive messages with the same time interval, until the timer is stopped.
BeOS:
The message to be sent will have the PM_TIMER constant in the what variable. The message will also contain an int16 value named "ID". This value contain the id specified when the timer was created. This is useful, if you use more than one timer at the same time.
Windows:
When the specific amount of time has passed, the timer will post a PM_TIMER message to a window using the specified window handle (HWND).The PM_TIMER message is in fact a WM_TIMER message. Thus it should be handled the same way as a WM_TIMER message. The posted message will contain an id, which is specified when the timer is created. This id can be found in the wParam member variable of the message structure (MSG). This id is useful for identifying the timer that sent the message, when several timers are running at the same time.
Derived from: None
Declared in: PTimer.h
PTimer(BLooper *looper, uint16 id); on BeOS PTimer(HWND window, uint16 id); on Windows
The constructor initialize the class variables and creates the timer. The first argument is different for each platform. See below for information on this argument. The second argument is an ID number. If you use more than one timer at the same time, you can give each timer an unique number. When you receive the timer message, you can extract the number from it to see which timer that got trigged.
BeOS:
The first argument is a pointer to the BLooper you want to receive the PM_TIMER message. This can be a window or a BApplication object.
Windows:
The first argument is a handle to a window that will receive the PM_TIMER message (WM_TIMER message).
~PTimer()
virtual ~PTimer(void);
Stops the timer and restore allocated resources.
void SetElapseValue(uint32 value);
Call this function before you start the timer. It sets the amount of time to wait, before the message is sent, when the timer expires. The value argument is the time in milliseconds.
StartTimer()
void StartTimer(void);
This function starts the timer. It begin sending messages with the time interval you specify by using the SetElapseValue() function or until you stop it with the StopTimer() function.
void StopTimer(void);
This function will stop the timer so it do not send messages any more.