MiniGUI API Reference (MiniGUI-Processes)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Data Structures | Macros | Typedefs | Functions
Initialization and termination functions

Normally, the only entry of any MiniGUI application is MiniGUIMain. The application will terminate when you call exit(3) or just return from MiniGUIMain. More...

Data Structures

struct  _DESKTOPOPS
 

Macros

#define ReinitDesktop()   ReinitDesktopEx (TRUE)
 Re-initializes the desktop including the local system text. More...
 
#define MiniGUIMain
 The main entry of a MiniGUI application. More...
 
#define IDM_DTI_FIRST   (300)
 The minimum interger value of command ID when user customize desktop menu. More...
 

Typedefs

typedef struct _DESKTOPOPS DESKTOPOPS
 

Functions

MG_EXPORT BOOL GUIAPI ReinitDesktopEx (BOOL init_sys_text)
 Re-initializes the desktop. More...
 
MG_EXPORT void GUIAPI ExitGUISafely (int exitcode)
 Exits your MiniGUI application safely. More...
 
MG_EXPORT DESKTOPOPS *GUIAPI SetCustomDesktopOperationSet (DESKTOPOPS *usr_dsk_ops)
 Set customer desktop operation set. More...
 
MG_EXPORT void GUIAPI DesktopUpdateAllWindow (void)
 Update all visible windows on the desktop. More...
 

Detailed Description

Normally, the only entry of any MiniGUI application is MiniGUIMain. The application will terminate when you call exit(3) or just return from MiniGUIMain.

Example 1:

/*
* This program parses the command line arguments.
* If the user specified a layer name by using "-layer <layer_name",
* the program will try to join the layer, otherwise create a new layer.
*/
int MiniGUIMain (int args, const char* arg[])
{
#ifdef _MGRM_PROCESSES
int i;
const char* layer = NULL;
for (i = 1; i < args; i++) {
if (strcmp (arg[i], "-layer") == 0) {
layer = arg[i + 1];
break;
}
}
printf ("GetLayerInfo: the requested layer does not exist.\n");
}
if (JoinLayer (layer, arg[0], 0, 0) == INV_LAYER_HANDLE) {
printf ("JoinLayer: invalid layer handle.\n");
exit (1);
}
#endif
...
return 0;
}

Example 2:

/*
* This is a every simple sample for MiniGUI.
* It will create a main window and display a string of "Hello, world!" in it.
*/
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <minigui/common.h>
#include <minigui/minigui.h>
#include <minigui/gdi.h>
#include <minigui/window.h>
static LRESULT HelloWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
HDC hdc;
switch (message) {
case MSG_PAINT:
hdc = BeginPaint (hWnd);
TextOut (hdc, 0, 0, "Hello, world!");
EndPaint (hWnd, hdc);
break;
case MSG_CLOSE:
return 0;
}
return DefaultMainWinProc(hWnd, message, wParam, lParam);
}
static void InitCreateInfo (PMAINWINCREATE pCreateInfo)
{
pCreateInfo->dwStyle = WS_CAPTION | WS_VISIBLE;
pCreateInfo->dwExStyle = 0;
pCreateInfo->spCaption = "Hello, world!" ;
pCreateInfo->hMenu = 0;
pCreateInfo->hCursor = GetSystemCursor (0);
pCreateInfo->hIcon = 0;
pCreateInfo->MainWindowProc = HelloWinProc;
pCreateInfo->lx = 0;
pCreateInfo->ty = 0;
pCreateInfo->rx = 320;
pCreateInfo->by = 240;
pCreateInfo->iBkColor = PIXEL_lightwhite;
pCreateInfo->dwAddData = 0;
pCreateInfo->hHosting = HWND_DESKTOP;
}
int MiniGUIMain (int args, const char* arg[])
{
MSG Msg;
MAINWINCREATE CreateInfo;
HWND hMainWnd;
#ifdef _MGRM_PROCESSES
JoinLayer (NAME_DEF_LAYER, arg[0], 0, 0);
#endif
InitCreateInfo (&CreateInfo);
hMainWnd = CreateMainWindow (&CreateInfo);
if (hMainWnd == HWND_INVALID)
return -1;
while (GetMessage (&Msg, hMainWnd)) {
}
return 0;
}

Macro Definition Documentation

◆ IDM_DTI_FIRST

#define IDM_DTI_FIRST   (300)

The minimum interger value of command ID when user customize desktop menu.

Definition at line 2559 of file minigui.h.

◆ MiniGUIMain

#define MiniGUIMain
Value:
MiniGUIAppMain (int args, const char* argv[]); \
int main_entry (int args, const char* argv[]) \
{ \
int iRet = 0; \
if (InitGUI (args, argv) != 0) { \
return 1; \
} \
iRet = MiniGUIAppMain (args, argv); \
TerminateGUI (iRet); \
return iRet; \
} \
int MiniGUIAppMain

The main entry of a MiniGUI application.

This function should be defined by your application. Before Version 1.6.1, MiniGUI defines main() function in libminigui library for your application, and call MiniGUIMain() in this main() function. The main() defined by MiniGUI is responsible of initializing and terminating MiniGUI.

After version 1.6.1, MiniGUI defines MiniGUIMain as a macro.

Parameters
argsThe number of arguments passed to main() by operating system.
argvThe arguments passed to main() by operating system.
Returns
The exit status will be retured to the parent process.

Definition at line 2540 of file minigui.h.

◆ ReinitDesktop

#define ReinitDesktop ( )    ReinitDesktopEx (TRUE)

Re-initializes the desktop including the local system text.

Returns
TRUE on success, otherwise FALSE.
Note
This function defined as a macro calling ReinitDesktopEx with init_sys_text set to TRUE.
See also
ReinitDesktopEx

Definition at line 2498 of file minigui.h.

Typedef Documentation

◆ DESKTOPOPS

typedef struct _DESKTOPOPS DESKTOPOPS

Desktop operation set

Function Documentation

◆ DesktopUpdateAllWindow()

void GUIAPI DesktopUpdateAllWindow ( void  )

Update all visible windows on the desktop.

On MiniGUI-Processes update all the main windows of the client and desktop window, and it only can be used by mginit on MiniGUI-Processes. On MiniGUI-Threads and MiniGUI-Standalone update all visible windows and desktop window.

◆ ExitGUISafely()

void GUIAPI ExitGUISafely ( int  exitcode)

Exits your MiniGUI application safely.

Calling this function will terminate your MiniGUI application. This function will restore console attributes and call exit() function and pass exitcode to it.

Parameters
exitcodeThe exit status will be passed to exit(3) function.
Returns
This function will not return.
See also
exit(3)

◆ ReinitDesktopEx()

BOOL GUIAPI ReinitDesktopEx ( BOOL  init_sys_text)

Re-initializes the desktop.

When you changed the charset or the background picture of the desktop, you should call this function to re-initialize the local system text (when init_sys_text is TRUE), the background picture, and the desktop menu.

Parameters
init_sys_textIndicates whether to initialize the local system text.
Returns
TRUE on success, otherwise FALSE.
See also
ReinitDesktop

◆ SetCustomDesktopOperationSet()

DESKTOPOPS *GUIAPI SetCustomDesktopOperationSet ( DESKTOPOPS usr_dsk_ops)

Set customer desktop operation set.

Parameters
usr_dsk_opsThe pointer to user customer desktop operation set.
Returns
Old desktop operation set.
static void* this_init(void)
{
......
}
static void this_deinit(void* context)
{
......
}
static void this_paint_desktop(void* context,
HDC dc_desktop, const RECT* inv_rc)
{
......
}
static void this_keyboard_handler(void* context, int message,
WPARAM wParam, LPARAM lParam)
{
......
}
static void this_mouse_handler(void* context, int message,
WPARAM wParam, LPARAM lParam)
{
......
}
static void this_customize_desktop_menu (void* context,
HMENU hmnu, int start_pos)
{
......
}
static void this_desktop_menucmd_handler (void* context, int id)
{
......
}
static DESKTOPOPS this_dsk_ops =
{
this_init,
this_deinit,
this_paint_desktop,
this_keyboard_handler,
this_mouse_handler,
this_customize_desktop_menu,
this_desktop_menucmd_handler,
};
See also
DESKTOPOPS
DestroyMainWindow
MG_EXPORT BOOL GUIAPI DestroyMainWindow(HWND hWnd)
Destroys a main window.
WS_VISIBLE
#define WS_VISIBLE
Creates a window initially visible.
Definition: window.h:4292
EndPaint
MG_EXPORT void GUIAPI EndPaint(HWND hWnd, HDC hdc)
Marks the end of painting in a window.
NULL
#define NULL
A value indicates null pointer.
Definition: common.h:369
CreateMainWindow
static HWND GUIAPI CreateMainWindow(PMAINWINCREATE pCreateInfo)
A simplified version of CreateMainWindowEx.
Definition: window.h:7046
_MAINWINCREATE::MainWindowProc
LRESULT(* MainWindowProc)(HWND, UINT, WPARAM, LPARAM)
Definition: window.h:6784
HWND
GHANDLE HWND
Handle to main window or control.
Definition: common.h:407
HDC
GHANDLE HDC
Handle to device context.
Definition: common.h:412
JoinLayer
MG_EXPORT GHANDLE GUIAPI JoinLayer(const char *layer_name, const char *client_name, int max_nr_highers, int max_nr_normals)
Joins to a layer.
GetSystemCursor
MG_EXPORT HCURSOR GUIAPI GetSystemCursor(int csrid)
Get the handle to a system cursor by its identifier.
MainWindowThreadCleanup
static BOOL MainWindowThreadCleanup(HWND hMainWnd)
Cleanup the main window.
Definition: window.h:6908
_MAINWINCREATE
Definition: window.h:6761
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
_RECT
Definition: common.h:936
HWND_DESKTOP
#define HWND_DESKTOP
Desktop window handle.
Definition: window.h:6742
_DESKTOPOPS
Definition: minigui.h:2562
HMENU
GHANDLE HMENU
Handle to menu.
Definition: common.h:432
PIXEL_lightwhite
#define PIXEL_lightwhite
Light white.
Definition: gdi.h:299
MSG_CLOSE
#define MSG_CLOSE
Indicates the user has clicked the closing box on the caption.
Definition: window.h:1413
_MAINWINCREATE::dwAddData
DWORD dwAddData
Definition: window.h:6795
_MSG
Definition: window.h:3148
HWND_INVALID
#define HWND_INVALID
Invalid window handle.
Definition: window.h:6754
_MAINWINCREATE::lx
int lx
Definition: window.h:6787
_MAINWINCREATE::hIcon
HICON hIcon
Definition: window.h:6778
_MAINWINCREATE::hCursor
HCURSOR hCursor
Definition: window.h:6775
MiniGUIMain
#define MiniGUIMain
The main entry of a MiniGUI application.
Definition: minigui.h:2540
InitGUI
MG_EXPORT int GUIAPI InitGUI(int argc, const char *argv[])
Initialize MiniGUI.
MSG_PAINT
#define MSG_PAINT
Sent to the window if the window contains an invalid region.
Definition: window.h:2127
PostQuitMessage
MG_EXPORT int GUIAPI PostQuitMessage(HWND hWnd)
Puts a MSG_QUIT message into the message queue of a main window.
_MAINWINCREATE::spCaption
const char * spCaption
Definition: window.h:6769
_MAINWINCREATE::hMenu
HMENU hMenu
Definition: window.h:6772
SetCustomDesktopOperationSet
MG_EXPORT DESKTOPOPS *GUIAPI SetCustomDesktopOperationSet(DESKTOPOPS *usr_dsk_ops)
Set customer desktop operation set.
DefaultMainWinProc
#define DefaultMainWinProc
Is the default main window callback procedure.
Definition: window.h:7383
GetLayerInfo
MG_EXPORT GHANDLE GUIAPI GetLayerInfo(const char *layer_name, int *nr_clients, BOOL *is_topmost, int *cli_active)
Get information of a layer by a client.
_MAINWINCREATE::iBkColor
gal_pixel iBkColor
Definition: window.h:6792
INV_LAYER_HANDLE
#define INV_LAYER_HANDLE
Invalid handle value of the layer.
Definition: minigui.h:271
_MAINWINCREATE::hHosting
HWND hHosting
Definition: window.h:6781
_MAINWINCREATE::dwStyle
DWORD dwStyle
Definition: window.h:6763
_MAINWINCREATE::dwExStyle
DWORD dwExStyle
Definition: window.h:6766
WS_CAPTION
#define WS_CAPTION
Creates a main window with caption.
Definition: window.h:4277
LPARAM
UINT_PTR LPARAM
A type definition for the second message paramter.
Definition: common.h:712
GetMessage
static BOOL GUIAPI GetMessage(PMSG pMsg, HWND hWnd)
Get a message from the message queue of a main window.
Definition: window.h:3240
DispatchMessage
MG_EXPORT LRESULT GUIAPI DispatchMessage(PMSG pMsg)
Dispatches a message to the window's callback procedure.
NAME_DEF_LAYER
#define NAME_DEF_LAYER
The default name of the layer.
Definition: minigui.h:437
TextOut
#define TextOut(hdc, x, y, text)
Outputs text.
Definition: gdi.h:10843
BeginPaint
MG_EXPORT HDC GUIAPI BeginPaint(HWND hWnd)
Prepares a window for painting.