MiniGUI API Reference (MiniGUI-Threads)  v3.2.0
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Data Structures | Macros | Typedefs | Functions | Variables
Window creating/destroying

Data Structures

struct  _MAINWINCREATE
 

Macros

#define HWND_DESKTOP   __mg_hwnd_desktop
 Desktop window handle. More...
 
#define HWND_NULL   ((HWND)0)
 Null window handle. More...
 
#define HWND_INVALID   ((HWND)-1)
 Invalid window handle. More...
 
#define MainWindowCleanup(hwnd)   MainWindowThreadCleanup(hwnd)
 Is an alias of MainWindowThreadCleanup. More...
 
#define DefaultMainWinProc   (__mg_def_proc[0])
 Is the default main window callback procedure. More...
 
#define DefaultDialogProc   (__mg_def_proc[1])
 The default dialog box procedure. More...
 
#define DefaultControlProc   (__mg_def_proc[2])
 The default control callback procedure. More...
 

Typedefs

typedef LRESULT(* WNDPROC) (HWND, UINT, WPARAM, LPARAM)
 Type of the window callback procedure. More...
 
typedef struct _MAINWINCREATE MAINWINCREATE
 

Functions

MG_EXPORT int GUIAPI CreateThreadForMainWindow (pthread_t *thread, pthread_attr_t *attr, void *(*start_routine)(void *), void *arg)
 Create a thread for main window. More...
 
MG_EXPORT pthread_t GUIAPI GetMainWinThread (HWND hMainWnd)
 Get the thread id which main window belongs to. More...
 
MG_EXPORT int GUIAPI WaitMainWindowClose (HWND hWnd, void **returnval)
 Suspends execution of the calling thread which main window belongs to until the target thread terminates, unless the target thread has already terminated. More...
 
MG_EXPORT void GUIAPI MainWindowThreadCleanup (HWND hMainWnd)
 Cleans up system resource associated with a main window. More...
 
MG_EXPORT HWND GUIAPI CreateMainWindowEx (PMAINWINCREATE pCreateInfo, const char *werdr_name, const WINDOW_ELEMENT_ATTR *we_attrs, const char *window_name, const char *layer_name)
 Creates a main window. More...
 
static HWND GUIAPI CreateMainWindow (PMAINWINCREATE pCreateInfo)
 A simplified version of CreateMainWindowEx. More...
 
MG_EXPORT BOOL GUIAPI DestroyMainWindow (HWND hWnd)
 Destroys a main window. More...
 
MG_EXPORT BOOL GUIAPI SetWindowMask (HWND hWnd, const MYBITMAP *mask)
 Set window (a main window, or a child window which is also known as "control")'s Mask Rect with MYBITMAP data. More...
 
MG_EXPORT BOOL GUIAPI SetWindowMaskEx (HWND hWnd, HDC hdc, const BITMAP *mask)
 Set window (a main window, or a child window which is also known as "control")'s Mask Rect with BITMAP data,. More...
 
BOOL GUIAPI SetWindowRegion (HWND hWnd, const CLIPRGN *region)
 Set window's Mask Rect with CLIPRGN data. More...
 
BOOL GUIAPI GetWindowRegion (HWND hWnd, CLIPRGN *region)
 The function obtains a copy of the window region of a window. More...
 
MG_EXPORT LRESULT GUIAPI DefaultWindowProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
 The default window callback procedure. More...
 

Variables

MG_EXPORT WNDPROC __mg_def_proc [3]
 The default window callback procedure array. More...
 

Detailed Description

Macro Definition Documentation

#define DefaultControlProc   (__mg_def_proc[2])

The default control callback procedure.

This function is the default control callback procedure. You should call this function for all messages, you do not want to handle in your own control procedure.

Parameters
hWndThe handle to the window.
messageThe message identifier.
wParamThe first parameter of the message.
lParamThe second parameter of the message.

Definition at line 5307 of file window.h.

#define DefaultDialogProc   (__mg_def_proc[1])

The default dialog box procedure.

This function is the default dialog box procedure. You should call this function in your dialog box procedure to process the unhandled messages.

Parameters
hWndThe handle to the window.
messageThe message identifier.
wParamThe first message parameter.
lParamThe second message parameter.
Returns
The return value of the message handler.

Definition at line 5292 of file window.h.

#define DefaultMainWinProc   (__mg_def_proc[0])

Is the default main window callback procedure.

This function is the default main window callback procedure. You should call this function for all messages, you do not want to handle in your main window procedure.

Parameters
hWndThe handle to the window.
messageThe message identifier.
wParamThe first parameter of the message.
lParamThe second parameter of the message.

Definition at line 5274 of file window.h.

#define HWND_DESKTOP   __mg_hwnd_desktop

Desktop window handle.

Definition at line 4972 of file window.h.

#define HWND_INVALID   ((HWND)-1)

Invalid window handle.

Definition at line 4984 of file window.h.

#define HWND_NULL   ((HWND)0)

Null window handle.

Definition at line 4978 of file window.h.

#define MainWindowCleanup (   hwnd)    MainWindowThreadCleanup(hwnd)

Is an alias of MainWindowThreadCleanup.

See also
MainWindowThreadCleanup

Definition at line 5091 of file window.h.

Typedef Documentation

typedef struct _MAINWINCREATE MAINWINCREATE

Structure defines a main window.

typedef int(* WNDPROC)(HWND, int, WPARAM, LPARAM)

Type of the window callback procedure.

Definition at line 4964 of file window.h.

Function Documentation

HWND GUIAPI CreateMainWindow ( PMAINWINCREATE  pCreateInfo)
inlinestatic

A simplified version of CreateMainWindowEx.

This function creates a main window by calling CreateMainWindow function and passing NULL for werdr_name, we_attrs, window_name, and layer_name parameters.

See also
CreateMainWindowEx

Definition at line 5132 of file window.h.

References __mg_def_proc, CreateMainWindowEx(), DefaultWindowProc(), DestroyMainWindow(), GetWindowRegion(), NULL, SetWindowMask(), SetWindowMaskEx(), and SetWindowRegion().

HWND GUIAPI CreateMainWindowEx ( PMAINWINCREATE  pCreateInfo,
const char *  werdr_name,
const WINDOW_ELEMENT_ATTR we_attrs,
const char *  window_name,
const char *  layer_name 
)

Creates a main window.

This function creates a main window by using some information, and returns the handle to the main window.

Parameters
pCreateInfoThe pointer to a MAINWINCREATE structure.
werdr_nameThe name of window element renderer. NULL for default renderer.
we_attrsThe pointer to window element attribute table. NULL for default window attribute table.
window_nameThe window name; reserved for future use.
layer_nameThe layer name; reserved for future use.
Returns
The handle to the new main window; HWND_INVALID indicates an error.
See also
CreateMainWindow, MAINWINCREATE, Window styles

Example:

/*
* The following code initializes a MAINWINCREATE struct and then
* creates a main window.
*/
{
MAINWINCREATE CreateInfo;
HWND hWnd;
/* Initialize the MAINWINCREATE structure. */
CreateInfo.spCaption= "MiniGUI step three";
CreateInfo.dwExStyle = WS_EX_NONE;
CreateInfo.hMenu = createmenu();
CreateInfo.hCursor = GetSystemCursor(0);
CreateInfo.hIcon = 0;
CreateInfo.MainWindowProc = MainWinProc;
CreateInfo.lx = 0;
CreateInfo.ty = 0;
CreateInfo.rx = 640;
CreateInfo.by = 480;
CreateInfo.iBkColor = COLOR_lightwhite;
CreateInfo.dwAddData = 0;
CreateInfo.hHosting = HWND_DESKTOP;
/* Create the main window. */
hWnd = CreateMainWindow(&CreateInfo);
if (hWnd == HWND_INVALID)
return 0;
}

Referenced by CreateMainWindow().

int GUIAPI CreateThreadForMainWindow ( pthread_t *  thread,
pthread_attr_t *  attr,
void *(*)(void *)  start_routine,
void *  arg 
)

Create a thread for main window.

See also
pthread_create
LRESULT DefaultWindowProc ( HWND  hWnd,
UINT  message,
WPARAM  wParam,
LPARAM  lParam 
)

The default window callback procedure.

This window procedure can be used for main windows, dialog boxes, and child windows.

This function is the default window callback procedure. You should call this function for all messages you do not want to handle in your window procedure.

Parameters
hWndThe handle to the window.
messageThe message identifier.
wParamThe first parameter of the message.
lParamThe second parameter of the message.

Referenced by CreateMainWindow().

BOOL GUIAPI DestroyMainWindow ( HWND  hWnd)

Destroys a main window.

This function destroys the main window specified by hWnd. It does not release all system resource used by the main window. You should call MainWindowThreadCleanup to destroy the main window actually.

Parameters
hWndThe handle to the main window.
Returns
TRUE on success, FALSE on error.
See also
MainWindowThreadCleanup

Example:

/*
* The following code destroies all resource used by the main window
* and then destroies the main window itself.
*/
case MSG_CLOSE:
/* Destroy the resource used by the main window. */
DestroyLogFont (logfont1);
DestroyLogFont (logfont2);
DestroyLogFont (logfont3);
/* Destroy the child windows. */
DestroyWindow(hWndButton);
DestroyWindow(hWndEdit);
/* Destroy the main window. */
/* Send a MSG_QUIT message to quit the message loop. */
return 0;

Referenced by CreateMainWindow().

pthread_t GUIAPI GetMainWinThread ( HWND  hMainWnd)

Get the thread id which main window belongs to.

Returns
Thread id.
BOOL GUIAPI GetWindowRegion ( HWND  hWnd,
CLIPRGN region 
)

The function obtains a copy of the window region of a window.

This function obtains a copy of the window region of a window. The window region of a window is set by calling the SetWindowRegion or SetWindowMaskEx function. The window region determines the area within the window where the system permits drawing. The system does not display any portion of a window that lies outside of the window region.

Parameters
hWndHandle to the window whose window region is to be obtained.
regionPointer to the region which will be modified to represent the window region.
Returns
return TRUE on success, otherwise FALSE.
See also
SetWindowRegion, SetWindowMaskEx

Referenced by CreateMainWindow().

void GUIAPI MainWindowThreadCleanup ( HWND  hMainWnd)

Cleans up system resource associated with a main window.

This function cleans up the system resource such as message queue associated with the main window hMainWnd. DestroyMainWindow does not destroy all resource used by a main window, therefore, you should call this function after calling DestroyMainWindow and skipping out from the message loop. After calling this function, the main window object will destroyed actually.

Parameters
hMainWndThe handle to the main window.
See also
DestroyMainWindow
BOOL GUIAPI SetWindowMask ( HWND  hWnd,
const MYBITMAP mask 
)

Set window (a main window, or a child window which is also known as "control")'s Mask Rect with MYBITMAP data.

Parameters
hWndThe handle to the window.
maskThe mask of the window which indicate the transparency of each pixel on this window.
Returns
return TRUE on success, otherwise FALSE.
See also
SetWindowRegion

Referenced by CreateMainWindow().

BOOL GUIAPI SetWindowMaskEx ( HWND  hWnd,
HDC  hdc,
const BITMAP mask 
)

Set window (a main window, or a child window which is also known as "control")'s Mask Rect with BITMAP data,.

Parameters
hWndThe handle to the window.
hdcThe reference dc which indicate the colorformat of the mask.
maskThe mask of the window which indicate the transparency of each pixel on this window.
Returns
return TRUE on success, otherwise FALSE.
See also
SetWindowRegion

Referenced by CreateMainWindow().

BOOL GUIAPI SetWindowRegion ( HWND  hWnd,
const CLIPRGN region 
)

Set window's Mask Rect with CLIPRGN data.

Parameters
hWndThe handle to the window.
regionThe region to indicate which part of the window is visible.
Returns
return TRUE on success, otherwise FALSE.

Referenced by CreateMainWindow().

int GUIAPI WaitMainWindowClose ( HWND  hWnd,
void **  returnval 
)

Suspends execution of the calling thread which main window belongs to until the target thread terminates, unless the target thread has already terminated.

Returns
non-NULL value on success.

Variable Documentation

WNDPROC __mg_def_proc[3]

The default window callback procedure array.

Referenced by CreateMainWindow().