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
Initialization and termination functions

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;
}
}
if (GetLayerInfo (layer, NULL, NULL, NULL) == INV_LAYER_HANDLE) {
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

#define IDM_DTI_FIRST   (300)

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

Definition at line 1506 of file minigui.h.

#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
MG_EXPORT int GUIAPI InitGUI(int, const char **)
Initialize MiniGUI.
MG_EXPORT void GUIAPI TerminateGUI(int not_used)
Terminate MiniGUI.

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 1487 of file minigui.h.

#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 1445 of file minigui.h.

Typedef Documentation

typedef struct _DESKTOPOPS DESKTOPOPS

Desktop operation set

Function Documentation

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.

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)
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
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.
1 static void* this_init(void)
2 {
3  ......
4 }
5 
6 static void this_deinit(void* context)
7 {
8  ......
9 }
10 
11 static void this_paint_desktop(void* context,\
12  HDC dc_desktop, const RECT* inv_rc)
13 {
14  ......
15 }
16 
17 static void this_keyboard_handler(void* context, int message,\
18  WPARAM wParam, LPARAM lParam)
19 {
20  ......
21 }
22 
23 static void this_mouse_handler(void* context, int message,\
24  WPARAM wParam, LPARAM lParam)
25 {
26  ......
27 }
28 
29 static void this_customize_desktop_menu (void* context,\
30  HMENU hmnu, int start_pos)
31 {
32  ......
33 }
34 
35 static void this_desktop_menucmd_handler (void* context, int id)
36 {
37  ......
38 }
39 
40 static DESKTOPOPS this_dsk_ops =
41 {
42  this_init,
43  this_deinit,
44  this_paint_desktop,
45  this_keyboard_handler,
46  this_mouse_handler,
47  this_customize_desktop_menu,
48  this_desktop_menucmd_handler,
49 };
50 
51 SetCustomDesktopOperationSet(&this_dsk_ops);
See also
DESKTOPOPS