MiniGUI API Reference (MiniGUI-Standalone)  v5.0.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 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...
 
#define DefaultVirtualWinProc   (__mg_def_proc[3])
 The default window callback procedure for virtual windows. More...
 

Typedefs

typedef struct _MAINWINCREATE MAINWINCREATE
 

Functions

MG_EXPORT BOOL GUIAPI MainWindowCleanup (HWND hMainWnd)
 Cleans up system resource associated with a main window. More...
 
static BOOL MainWindowThreadCleanup (HWND hMainWnd)
 Cleanup the main window. More...
 
MG_EXPORT HWND GUIAPI CreateMainWindowEx2 (PMAINWINCREATE create_info, LINT id, const char *werdr_name, const WINDOW_ELEMENT_ATTR *we_attrs, unsigned int surf_flag, DWORD bkgnd_color, int compos_type, DWORD ct_arg)
 Creates a main window with specified compositing type and identifier. More...
 
static 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 SetWindowLocalData (HWND hwnd, const char *data_name, DWORD local_data, CB_FREE_LOCAL_DATA cb_free)
 Set the local data bound with a name for a window. More...
 
MG_EXPORT BOOL GUIAPI RemoveWindowLocalData (HWND hwnd, const char *data_name)
 Remove the local data bound with a name for a window. More...
 
MG_EXPORT BOOL GUIAPI GetWindowLocalData (HWND hwnd, const char *data_name, DWORD *local_data, CB_FREE_LOCAL_DATA *cb_free)
 Retrieve the local data bound with a name for a 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...
 
MG_EXPORT BOOL GUIAPI SetMainWindowAlwaysTop (HWND hWnd, BOOL fSet)
 Set or cancel a main window being always top. 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 [4]
 The default window callback procedure array. More...
 

Detailed Description

Macro Definition Documentation

◆ DefaultControlProc

#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 7351 of file window.h.

◆ DefaultDialogProc

#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 7336 of file window.h.

◆ DefaultMainWinProc

#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 7318 of file window.h.

◆ DefaultVirtualWinProc

#define DefaultVirtualWinProc   (__mg_def_proc[3])

The default window callback procedure for virtual windows.

This function is the default window callback procedure for virtual windows. You should call this function for any message which you do not want to handle in your own callback 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 7367 of file window.h.

◆ HWND_DESKTOP

#define HWND_DESKTOP   __mg_hwnd_desktop

Desktop window handle.

Definition at line 6710 of file window.h.

◆ HWND_INVALID

#define HWND_INVALID   ((HWND)-1)

Invalid window handle.

Definition at line 6722 of file window.h.

◆ HWND_NULL

#define HWND_NULL   ((HWND)0)

Null window handle.

Definition at line 6716 of file window.h.

Typedef Documentation

◆ MAINWINCREATE

typedef struct _MAINWINCREATE MAINWINCREATE

Structure defines a main window.

Function Documentation

◆ CreateMainWindow()

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 7014 of file window.h.

◆ CreateMainWindowEx()

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

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, ignored currently.
layer_nameThe layer name, ignored currently.
Returns
The handle to the new main window; HWND_INVALID indicates an error.
See also
CreateMainWindow, MAINWINCREATE, Window styles
Note
Since 5.0.0, this function is implemented as an inline function calling CreateMainWindowEx2. When calling CreateMainWindowEx2:
  • We pass 0 for the identifier.
  • We pass 0xFFFFFFFFUL for the background color.
  • We discard the values passed to window_name and layer_name.

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;
}
See also
CreateMainWindowEx2

Definition at line 6996 of file window.h.

◆ CreateMainWindowEx2()

HWND GUIAPI CreateMainWindowEx2 ( PMAINWINCREATE  create_info,
LINT  id,
const char *  werdr_name,
const WINDOW_ELEMENT_ATTR we_attrs,
unsigned int  surf_flag,
DWORD  bkgnd_color,
int  compos_type,
DWORD  ct_arg 
)

Creates a main window with specified compositing type and identifier.

This function creates a main window by using information and the specified compositing type and identifier, then returns the handle to the main window.

Parameters
create_infoThe 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.
idThe window identifier.
surf_flagThe flag for the surface of the main window under compositing schema. The value of this argument can be one of the following values:
  • ST_PIXEL_DEFAULT
    Creating a surface which compliant to HDC_SCREEN.
  • ST_PIXEL_ARGB4444
    Creating a surface for this main window with the pixel format ARGB4444.
  • ST_PIXEL_ARGB1555
    Creating a surface for this main window with the pixel format ARGB1555.
  • ST_PIXEL_ARGB8888
    Creating a surface for this main window with the pixel format ARGB8888.
bkgnd_colorThe background color of the main window if you specify the main window's surface type other than the default. In this case, you must use this argument to specify the background color of the main window instead of the pixel value of the field (iBkColor) in MAINWINCREATE structure. The value of this field is a 32-bit RGBA quadruple essentially. You can use a value returned by MakeRGBA macro for this argument. Note that if you use the surface type ST_PIXEL_DEFAULT when creating the main window, you can still use the pixel values specified in MAINWINCREATE structure which is compliant to HDC_SCREEN, e.g., a value in SysPixelIndex array.
compos_typeThe compositing type of the main window.
ct_argThe compositing argument of the main window.
Returns
The handle to the new main window; HWND_INVALID indicates an error.
Note
Note When you specify a surface type other than ST_PIXEL_DEFAULT, you must use bkgnd_color to specify the background color of the main window.
See also
CreateMainWindowEx, 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;
}

◆ DefaultWindowProc()

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.

◆ DestroyMainWindow()

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;

◆ GetWindowLocalData()

BOOL GUIAPI GetWindowLocalData ( HWND  hwnd,
const char *  data_name,
DWORD local_data,
CB_FREE_LOCAL_DATA *  cb_free 
)

Retrieve the local data bound with a name for a window.

This function retrieves the local data which is bound with the name data_name for the specified window hwnd.

Parameters
hwndThe handle to the window, which can be a main window, a virtual window or a control.
data_nameThe name for the local data.
local_dataThe pointer to a DWORD variable to return the local data if it is not NULL.
cb_freeThe pointer to a CB_FREE_LOCAL_DATA variable to return the pointer to the callback function which is used to free the local data if it is not NULL.
Returns
TRUE on success, FALSE on error.
See also
SetWindowLocalData, RemoveWindowLocalData

Since 5.0.0

◆ GetWindowRegion()

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

◆ MainWindowCleanup()

BOOL GUIAPI MainWindowCleanup ( HWND  hMainWnd)

Cleans up system resource associated with a main window.

This function cleans up the system resource such as the 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 be destroyed actually.

Parameters
hMainWndThe handle to the main window.
Returns
TRUE on success, otherwise FALSE.
See also
DestroyMainWindow
Note
Since 5.0.0, this function returns a BOOL value. If you try to clean up a main window in a thread other than it belongs to, the function will fail.

Referenced by MainWindowThreadCleanup().

◆ MainWindowThreadCleanup()

BOOL MainWindowThreadCleanup ( HWND  hMainWnd)
inlinestatic

Cleanup the main window.

Parameters
hMainWndThe handle to the main window.
Returns
TRUE on success, otherwise FALSE.
Note
Deprecated; please use MainWindowCleanup() instead.
See also
MainWindowCleanup

Definition at line 6876 of file window.h.

References MainWindowCleanup().

◆ RemoveWindowLocalData()

BOOL GUIAPI RemoveWindowLocalData ( HWND  hwnd,
const char *  data_name 
)

Remove the local data bound with a name for a window.

This function removes the local data which is bound with the name data_name for the specified window hwnd. When you pass NULL for data_name, this function will remove all local data of the window. Note that this function will call the callback procedure for releasing the local data, if you had set it, when removing the local data.

Parameters
hwndThe handle to the window, which can be a main window, a virtual window or a control.
data_nameThe name for the local data.
Returns
TRUE on success, FALSE on error.
See also
SetWindowLocalData, GetWindowLocalData

Since 5.0.0

◆ SetMainWindowAlwaysTop()

BOOL GUIAPI SetMainWindowAlwaysTop ( HWND  hWnd,
BOOL  fSet 
)

Set or cancel a main window being always top.

This function set or cancel a main window being always top on others. If it succeed, the main window will have the style WS_ALWAYSTOP.

Parameters
hWndThe handle to the window.
fSetSet or cancel the always top style; TRUE to set, FALSE to cancel.
Returns
return TRUE on success, otherwise FALSE.
See also
GetWindowStyle, WS_ALWAYSTOP

Since 5.0.0

◆ SetWindowLocalData()

BOOL GUIAPI SetWindowLocalData ( HWND  hwnd,
const char *  data_name,
DWORD  local_data,
CB_FREE_LOCAL_DATA  cb_free 
)

Set the local data bound with a name for a window.

This function sets the local data as local_data which is bound with the name data_name for the specified window hwnd. If you passed a non-NULL function pointer for cb_free, the system will call this function to free the local data when you destroy the window, remove the local data, or when you call this function to overwrite the old local data for the name.

Parameters
hwndThe handle to the window, which can be a main window, a virtual window or a control.
data_nameThe name of the local data.
local_dataThe value of the local data.
cb_freeA callback function which will be called automatically by the system to free the local data when the window is being destroyed or the local data is being removed or overwritten. If it is NULL, the system does nothing to the local data.
Returns
TRUE on success, FALSE on error.
See also
GetWindowLocalData, RemoveWindowLocalData

Since 5.0.0

◆ SetWindowMask()

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

◆ SetWindowMaskEx()

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

◆ SetWindowRegion()

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.

Variable Documentation

◆ __mg_def_proc

WNDPROC __mg_def_proc[]

The default window callback procedure array.