MiniGUI API Reference (MiniGUI-Processes)  v3.2.0
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Macros | Functions

Macros

#define MAX_NR_LISTEN_FD   5
 The max number of listen fd which user can use. More...
 

Functions

MG_EXPORT BOOL GUIAPI RegisterListenFD (int fd, int type, HWND hwnd, void *context)
 Registers a listening file descriptor to MiniGUI-Lite. More...
 
MG_EXPORT BOOL GUIAPI UnregisterListenFD (int fd)
 Unregisters a being listened file descriptor. More...
 

Detailed Description

Register/Unregister a listen fd to MiniGUI.

When you need to listen a file descriptor, you can use select(2) system call. In MiniGUI, you can also register it to MiniGUI to be a listened fd, and when there is a read/write/except event on the registered fd , MiniGUI will sent a notification message to the registered window.

Example:

...
/* Register to listen the read event of the master pty. */
RegisterListenFD (pConInfo->masterPty, POLLIN, hMainWnd, 0);
/* Enter the message loop. */
while (!pConInfo->terminate && GetMessage (&Msg, hMainWnd)) {
}
/* Unregister the listening fd. */
UnregisterListenFD (pConInfo->masterPty);
...
/* The window procedure. */
static LRESULT VCOnGUIMainWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
PCONINFO pConInfo;
pConInfo = (PCONINFO)GetWindowAdditionalData (hWnd);
switch (message) {
...
/* MSG_FDEVENT sent by MiniGUI indicates that you should to read the data. */
ReadMasterPty (pConInfo);
break;
...
}
/* Calling default window procedure. */
if (pConInfo->DefWinProc)
return (*pConInfo->DefWinProc)(hWnd, message, wParam, lParam);
else
return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

Macro Definition Documentation

#define MAX_NR_LISTEN_FD   5

The max number of listen fd which user can use.

Definition at line 324 of file minigui.h.

Function Documentation

BOOL GUIAPI RegisterListenFD ( int  fd,
int  type,
HWND  hwnd,
void *  context 
)

Registers a listening file descriptor to MiniGUI-Lite.

This function registers the file desciptor fd to MiniGUI-Lite for listening.

When there is a read/write/except event on this fd, MiniGUI will post a MSG_FDEVENT message with wParam being equal to MAKELONG (fd, type), and the lParam being set to context to the target window hwnd.

Parameters
fdThe file descriptor to be listened.
typeThe type of the event to be listened, can be POLLIN, POLLOUT, or POLLERR.
hwndThe handle to the window will receive MSG_FDEVENT message.
contextThe value will be passed to the window as lParam of MSG_FDEVENT message.
Returns
TRUE if all OK, and FALSE on error.
Note
Only available on MiniGUI-Processes.
See also
UnregisterListenFD, System messages
BOOL GUIAPI UnregisterListenFD ( int  fd)

Unregisters a being listened file descriptor.

This function unregisters the being listened file descriptor fd.

Parameters
fdThe file descriptor to be unregistered, should be a being listened file descriptor.
Returns
TRUE if all OK, and FALSE on error.
Note
Only available on MiniGUI-Processes.
See also
RegisterListenFD