MiniGUI API Reference (MiniGUI-Processes)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Macros | Typedefs | Functions
Timer operations

Macros

#define SetTimer(hwnd, id, speed)   SetTimerEx(hwnd, id, speed, NULL)
 The backward compatibility version of SetTimerEx. More...
 
#define ResetTimer(hwnd, id, speed)   ResetTimerEx(hwnd, id, speed, (TIMERPROC)INV_PTR)
 The backward compatibility version of ResetTimerEx. More...
 

Typedefs

typedef BOOL(* TIMERPROC) (HWND, LINT, DWORD)
 Type of the timer callback procedure. More...
 

Functions

MG_EXPORT BOOL GUIAPI SetTimerEx (HWND hWnd, LINT id, DWORD speed, TIMERPROC timer_proc)
 Creates a timer with the specified timeout value. More...
 
MG_EXPORT int GUIAPI KillTimer (HWND hWnd, LINT id)
 Destroys a timer. More...
 
MG_EXPORT BOOL GUIAPI ResetTimerEx (HWND hWnd, LINT id, DWORD speed, TIMERPROC timer_proc)
 Adjusts a timer with a different timeout value or different timer callback procedure. More...
 
MG_EXPORT BOOL GUIAPI IsTimerInstalled (HWND hWnd, LINT id)
 Determine whether a timer is installed. More...
 
MG_EXPORT BOOL GUIAPI HaveFreeTimer (void)
 Determine whether there is any free timer slot in the current thread. More...
 

Detailed Description

Macro Definition Documentation

◆ ResetTimer

#define ResetTimer (   hwnd,
  id,
  speed 
)    ResetTimerEx(hwnd, id, speed, (TIMERPROC)INV_PTR)

The backward compatibility version of ResetTimerEx.

See also
ResetTimerEx

Definition at line 10116 of file window.h.

◆ SetTimer

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

The backward compatibility version of SetTimerEx.

See also
SetTimerEx

Definition at line 10063 of file window.h.

Typedef Documentation

◆ TIMERPROC

typedef BOOL(* TIMERPROC)(HWND, LINT, 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
Note
The prototype had changed since MiniGUI v3.2; the old one:
 BOOL (* TIMERPROC)(HWND, int, unsigned int)

Definition at line 10011 of file window.h.

Function Documentation

◆ HaveFreeTimer()

BOOL GUIAPI HaveFreeTimer ( void  )

Determine whether there is any free timer slot in the current thread.

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

Returns
TRUE for yes, otherwise FALSE.
See also
IsTimerInstalled

◆ IsTimerInstalled()

BOOL GUIAPI IsTimerInstalled ( HWND  hWnd,
LINT  id 
)

Determine whether a timer is installed.

This function determines whether a timer with identifier id for a window hwnd has been installed in the current thread.

Parameters
hWndThe window owns the timer.
idThe identifier of the timer.
Returns
TRUE for installed, otherwise FALSE.
See also
SetTimer, HaveFreeTimer
Note
The prototype had changed since MiniGUI v3.2; the old one: BOOL GUIAPI IsTimerInstalled (HWND hWnd, int id)

◆ KillTimer()

int GUIAPI KillTimer ( HWND  hWnd,
LINT  id 
)

Destroys a timer.

This function destroys the specified timer id.

Parameters
hWndThe window owns the timer.
idThe identifier of the timer. If id is 0, this function will kill all timers of created by the window.
Returns
The number of actually killed timer.
See also
SetTimer
Note
The prototype had changed since MiniGUI v3.2; the old one: int GUIAPI KillTimer (HWND hWnd, int id)

◆ ResetTimerEx()

BOOL GUIAPI ResetTimerEx ( HWND  hWnd,
LINT  id,
DWORD  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
hWndThe window owns the timer.
idThe identifier of the timer.
speedThe new timeout value.
timer_procThe new timer callback procedure. If timer_proc is INV_PTR, the setting of timer callback procedure will not change.
Returns
TRUE on success, FALSE on error.
See also
SetTimerEx
Note
The prototype had changed since MiniGUI v3.2; the old one: BOOL GUIAPI ResetTimerEx (HWND hWnd, int id, unsigned int speed, TIMERPROC timer_proc)

◆ SetTimerEx()

BOOL GUIAPI SetTimerEx ( HWND  hWnd,
LINT  id,
DWORD  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 the 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.

Since 5.0.0, if the specified timer already exists when you call this function, MiniGUI will reset the timer by using the new parameters.

Parameters
hWndThe 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.
idThe identifier of the timer, will be passed to the window with MSG_TIMER message as the first parameter of the message.
speedThe timeout value of the timer. Note that the timeout value is in unit of 10 ms.
timer_procThe 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 message thread if your enabled support for the virtual window.
The prototype had changed since MiniGUI v3.2; the old one:
 BOOL SetTimerEx (HWND hWnd, int id, unsigned int speed, \
         TIMERPROC timer_proc);

Example:

/*
* A typical handling of timer.
*/
LRESULT FlyingGUIWinProc (HWND hWnd, UINT 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. */
break;
case MSG_CLOSE:
/* kill the timer whose id is 100. */
KillTimer (hWnd, 100);
return 0;
}
return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
DestroyMainWindow
MG_EXPORT BOOL GUIAPI DestroyMainWindow(HWND hWnd)
Destroys a main window.
NULL
#define NULL
A value indicates null pointer.
Definition: common.h:369
MSG_CREATE
#define MSG_CREATE
Indicates the window has been created, and gives you a chance to initialize your private objects.
Definition: window.h:1352
HWND
GHANDLE HWND
Handle to main window or control.
Definition: common.h:407
SetTimer
#define SetTimer(hwnd, id, speed)
The backward compatibility version of SetTimerEx.
Definition: window.h:10063
WPARAM
UINT_PTR WPARAM
A type definition for the first message paramter.
Definition: common.h:706
LRESULT
LONG_PTR LRESULT
Signed result of message processing.
Definition: common.h:583
UINT
unsigned int UINT
A type definition for unsigned integer.
Definition: common.h:664
FALSE
#define FALSE
FALSE value, defined as 0 by MiniGUI.
Definition: common.h:351
MSG_CLOSE
#define MSG_CLOSE
Indicates the user has clicked the closing box on the caption.
Definition: window.h:1413
PostQuitMessage
MG_EXPORT int GUIAPI PostQuitMessage(HWND hWnd)
Puts a MSG_QUIT message into the message queue of a main window.
MSG_TIMER
#define MSG_TIMER
Indicates a timer has expired.
Definition: window.h:2928
KillTimer
MG_EXPORT int GUIAPI KillTimer(HWND hWnd, LINT id)
Destroys a timer.
DefaultMainWinProc
#define DefaultMainWinProc
Is the default main window callback procedure.
Definition: window.h:7383
InvalidateRect
MG_EXPORT BOOL GUIAPI InvalidateRect(HWND hWnd, const RECT *prc, BOOL bEraseBkgnd)
Makes a rectangle region in the client area of a window invalid.
LPARAM
UINT_PTR LPARAM
A type definition for the second message paramter.
Definition: common.h:712