MiniGUI API Reference (MiniGUI-Processes)
v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
|
You know that we can post or send a message to other windows which may run in another thread under MiniGUI-Threads. The MiniGUI messaging functions such as PostMessage(), SendMessage(), SendNotifyMessage(), and the window callback procedure provide a flexible, efficient, safe, and easy-to-use data transfer and synchronization mechanism for your multithreaded applications. More...
Functions | |
MG_EXPORT BOOL GUIAPI | GetThreadByWindow (HWND hWnd, pthread_t *thread) |
Get the thread identifier which a window belongs to. More... | |
MG_EXPORT BOOL GUIAPI | IsWindowInThisThread (HWND hWnd) |
Determine whether a window was created in this thread. More... | |
MG_EXPORT BOOL GUIAPI | VirtualWindowCleanup (HWND hVirtWnd) |
Cleanup the system resource associated with a virtual window. More... | |
MG_EXPORT HWND GUIAPI | CreateVirtualWindow (HWND hHosting, WNDPROC WndProc, const char *spCaption, LINT id, DWORD dwAddData) |
Create a virtual window. More... | |
MG_EXPORT BOOL GUIAPI | DestroyVirtualWindow (HWND hWnd) |
Destroy a virtual window. More... | |
You know that we can post or send a message to other windows which may run in another thread under MiniGUI-Threads. The MiniGUI messaging functions such as PostMessage(), SendMessage(), SendNotifyMessage(), and the window callback procedure provide a flexible, efficient, safe, and easy-to-use data transfer and synchronization mechanism for your multithreaded applications.
For example, you can send or post a message to a window from a general purpose thread which may download a file from the remote server under MiniGUI-Threads.
But can we use the MiniGUI messaging mechanism under MiniGUI-Processes and MiniGUI-Standalone runtime modes for multithreading purpose? For example, we may download a file in a general thread and inform a window when the file is ready.
Furthermore, if we want to use the MiniGUI messaging mechanism in a general thread to handle messages from other threads, how to do this?
The virtual window provides a solution for the requirements above. A virtual window is a special window object which does not have a visible window area. But after you create a virtual window in a different thread, you can use the MiniGUI messaging mechanism to post or send messages between the current main window thread and the new thread.
In MiniGUI, we call a thread creating a main window as a GUI thread, and a thread creating a virtual window as a message thread.
It is important to know the following key points about virtual window:
--enable-virtualwindow
, or define _MGHAVE_VIRTUAL_WINDOW
macro under MiniGUI-Processes and MiniGUI-Standalone runtime modes.A virtual window will get the following system messages in its life life-cycle:
The following functions work for a virtual window:
Since 5.0.0.
HWND GUIAPI CreateVirtualWindow | ( | HWND | hHosting, |
WNDPROC | WndProc, | ||
const char * | spCaption, | ||
LINT | id, | ||
DWORD | dwAddData | ||
) |
Create a virtual window.
This function creates a virtual window for the purpose of multi-thread messaging.
hHosting | The hosting virutal window. |
WndProc | The window callback procedure. |
spCaption | The caption of the virtual window. |
id | The long integer (pointer size) identifier of the virtual window. |
dwAddData | The additional data for the window. |
Example:
Since 5.0.0.
Destroy a virtual window.
This function destroys a virtual window.
hWnd | The handle to the virtual window. |
Example:
Since 5.0.0.
Get the thread identifier which a window belongs to.
hWnd | The handle to a window, which may be a main window, virtual window, or a control. |
thread | The buffer to store the thread identifier. |
Since 5.0.0
Determine whether a window was created in this thread.
hWnd | The handle to a window, which may be a main window, virtual window, or a control. |
Since 5.0.0
Cleanup the system resource associated with a virtual window.
This function cleans up the system resource such as the message queue associated with the virual window hVirtWnd. DestroyVirtualWindow does not destroy all resource used by the virtual window, therefore, you should call this function after calling DestroyVirtualWindow and skipping out from the message loop. After calling this function, the virtual window object will be destroyed actually.
hVirtWnd | The handle to the virtual window. |
Since 5.0.0