Timer operations
[Window creating/destroying]

Defines

Typedefs

Functions


Define Documentation

#define ResetTimer ( hwnd,
id,
speed   )     ResetTimerEx(hwnd, id, speed, (TIMERPROC)0xFFFFFFFF)

The backward compatibility version of ResetTimerEx.

See also:
ResetTimerEx

Definition at line 7299 of file window.h.

#define SetTimer ( hwnd,
id,
speed   )     SetTimerEx(hwnd, id, speed, NULL)

The backward compatibility version of SetTimerEx.

See also:
SetTimerEx

Definition at line 7252 of file window.h.


Typedef Documentation

typedef BOOL(* TIMERPROC)(HWND, int, DWORD)

Type of the timer callback procedure.

This is the prototype of the callback procedure of a timer created by SetTimerEx. MiniGUI will call the timer procedure instead of sending MSG_TIMER message.

If the return value of a timer procedure is FALSE, the timer will be killed by MiniGUI automatically. This can be used to implement a one-shot timer.

See also:
SetTimerEx

Definition at line 7208 of file window.h.


Function Documentation

unsigned int GUIAPI GetTickCount ( void   ) 

Retrieves the tick counts that have elapsed since MiniGUI was started.

This function retrieves the tick counts that have elapsed since MiniGUI was started. It is limited to the resolution of the system timer, i.e. for a general Linux box, the returned tick count value is in unit of 10ms.

Returns:
The tick counts value that have elapsed since MiniGUI was started.
BOOL GUIAPI HaveFreeTimer ( void   ) 

Determines whether there is any free timer slot in the system.

This function determines whether there is any free timer slot in the system.

Returns:
TRUE for yes, otherwise FALSE.
See also:
IsTimerInstalled
BOOL GUIAPI IsTimerInstalled ( HWND  hWnd,
int  id 
)

Determines whether a timer is installed.

This function determines whether a timer with identifier id of a window hwnd has been installed.

Parameters:
hWnd The window owns the timer.
id The identifier of the timer.
Returns:
TRUE for installed, otherwise FALSE.
See also:
SetTimer, HaveFreeTimer
int GUIAPI KillTimer ( HWND  hWnd,
int  id 
)

Destroys a timer.

This function destroys the specified timer id.

Parameters:
hWnd The window owns the timer.
id The identifier of the timer. If id equals or is less than 0, this function will kill all timers in the system.
Returns:
The number of actually killed timer.
See also:
SetTimer
BOOL GUIAPI ResetTimerEx ( HWND  hWnd,
int  id,
unsigned int  speed,
TIMERPROC  timer_proc 
)

Adjusts a timer with a different timeout value or different timer callback procedure.

This function resets a timer with the specified timeout speed value.

Parameters:
hWnd The window owns the timer.
id The identifier of the timer.
speed The new timeout value.
timer_proc The new timer callback procedure. If timer_proc is 0xFFFFFFFF, the setting of timer callback procedure will not changed.
Returns:
TRUE on success, FALSE on error.
See also:
SetTimerEx
BOOL GUIAPI SetTimerEx ( HWND  hWnd,
int  id,
unsigned int  speed,
TIMERPROC  timer_proc 
)

Creates a timer with the specified timeout value.

This function creates a timer with the specified timeout value speed. Note that the timeout value is in unit of 10 ms. When the timer expires, an MSG_TIMER message will be send to the window hWnd if timer_proc is NULL, otherwise MiniGUI will call timer_proc by passing hWnd, id, and the tick count when this timer had expired to this callback procedure.

Parameters:
hWnd The window receives the MSG_TIMER message. If timer_proc is not NULL, MiniGUI will call timer_proc instead sending MSG_TIMER message to this window. If you use timer callback procedure, hWnd can be any value you can pass.
id The identifier of the timer, will be passed to the window with MSG_TIMER message as the first parameter of the message.
speed The timeout value of the timer. Note that the timeout value is in unit of 10 ms.
timer_proc The timer callback procedure. If this argument is NULL, MiniGUI will send MSG_TIMER to the window procedure of hWnd.
Returns:
TRUE on success, FALSE on error.
See also:
SetTimer, ResetTimerEx, KillTimer, MSG_TIMER
Note:
You should set, reset, and kill a timer in the same thread if your MiniGUI is configured as MiniGUI-Threads.

Example:

/*
 * A typical handling of timer.
 */
int FlyingGUIWinProc (HWND hWnd, int message, WPARAM wParam, LPARAM lParam)
{
    switch (message) {
        case MSG_CREATE:
        /* create a timer which expires every 100 ms, and whose id is 100. */
#ifdef _MGTIMER_UNIT_10MS
            SetTimer (hWnd, 100, 10);
#else
            SetTimer (hWnd, 100, 100);
#endif
        break;

        /* handling the MSG_TIMER message. */
        case MSG_TIMER:
            if (wParam == 100) /* if it is the timer whose id is 100. */
                InvalidateRect (hWnd, NULL, FALSE);
        break;

        case MSG_CLOSE:
            /* kill the timer whose id is 100. */
            KillTimer (hWnd, 100);
            DestroyMainWindow (hWnd);
            PostQuitMessage (hWnd);
        return 0;
    }

    return DefaultMainWinProc(hWnd, message, wParam, lParam);
}

Generated on Thu Apr 7 15:58:41 2011 for MiniGUI V3.0.12 API Reference by  doxygen 1.6.3