MiniGUI API Reference (MiniGUI-Processes)  v5.0.6
A mature and proven cross-platform GUI system for embedded and smart IoT devices
Macros | Functions
General window operations

Macros

#define SetFocus   SetFocusChild
 
#define GetFocus   GetFocusChild
 
#define GetForegroundWindow   GetActiveWindow
 
#define SetForegroundWindow   SetActiveWindow
 
#define GetWindowElementPixel(hWnd, iItem)   GetWindowElementPixelEx(hWnd, HDC_INVALID, iItem)
 Get window element pixel value. More...
 

Functions

MG_EXPORT void GUIAPI UpdateWindow (HWND hWnd, BOOL bErase)
 Updates a window. More...
 
MG_EXPORT void GUIAPI UpdateInvalidClient (HWND hWnd, BOOL bErase)
 Updates the invalid client areas in a window. More...
 
MG_EXPORT BOOL GUIAPI ShowWindow (HWND hWnd, int iCmdShow)
 Shows or hides a window. More...
 
MG_EXPORT BOOL GUIAPI EnableWindow (HWND hWnd, BOOL fEnable)
 Enables of disables a window. More...
 
MG_EXPORT BOOL GUIAPI IsWindowEnabled (HWND hWnd)
 Determine whether the specified window is enabled for mouse and keyboard input. More...
 
MG_EXPORT BOOL GUIAPI GetClientRect (HWND hWnd, PRECT prc)
 Retrieve the client rectangle of a window. More...
 
MG_EXPORT gal_pixel GUIAPI DWORD2PixelByWindow (HWND hWnd, DWORD dwColor)
 Convert a DWORD color to gal_pixel for a window. More...
 
MG_EXPORT gal_pixel GUIAPI GetWindowBkColor (HWND hWnd)
 Returns the current background color of a window. More...
 
MG_EXPORT gal_pixel GUIAPI SetWindowBkColor (HWND hWnd, gal_pixel new_bkcolor)
 Set the background color of a window. More...
 
MG_EXPORT PLOGFONT GUIAPI GetWindowFont (HWND hWnd)
 Retrieve the default font of a window. More...
 
MG_EXPORT PLOGFONT GUIAPI SetWindowFont (HWND hWnd, PLOGFONT pLogFont)
 Set the default font of a window. More...
 
MG_EXPORT HCURSOR GUIAPI GetWindowCursor (HWND hWnd)
 Retrieve the current cursor of a window. More...
 
MG_EXPORT HCURSOR GUIAPI SetWindowCursor (HWND hWnd, HCURSOR hNewCursor)
 Set the current cursor of a window. More...
 
MG_EXPORT HICON GUIAPI GetWindowIcon (HWND hWnd)
 Retrieve the current icon of a window. More...
 
MG_EXPORT HICON GUIAPI SetWindowIcon (HWND hWnd, HICON hIcon, BOOL bRedraw)
 Set the current icon of a window. More...
 
MG_EXPORT DWORD GUIAPI GetWindowStyle (HWND hWnd)
 Retrieve the style of a window. More...
 
MG_EXPORT DWORD GUIAPI GetWindowExStyle (HWND hWnd)
 Retrieve the extended style of a window. More...
 
MG_EXPORT BOOL GUIAPI ExcludeWindowStyle (HWND hWnd, DWORD dwStyle)
 Removes the specific style of a window. More...
 
MG_EXPORT BOOL GUIAPI IncludeWindowStyle (HWND hWnd, DWORD dwStyle)
 Includes the specific style of a window. More...
 
MG_EXPORT BOOL GUIAPI ExcludeWindowExStyle (HWND hWnd, DWORD dwStyle)
 Removes the specific extended style of a window. More...
 
MG_EXPORT BOOL GUIAPI IncludeWindowExStyle (HWND hWnd, DWORD dwStyle)
 Includes the specific extended style of a window. More...
 
MG_EXPORT WNDPROC GUIAPI GetWindowCallbackProc (HWND hWnd)
 Retrieve the callback procedure of a window. More...
 
MG_EXPORT WNDPROC GUIAPI SetWindowCallbackProc (HWND hWnd, WNDPROC newProc)
 Set the callback procedure of a window. More...
 
MG_EXPORT DWORD GUIAPI GetWindowAdditionalData (HWND hWnd)
 Retrieve the first additional data of a window. More...
 
MG_EXPORT DWORD GUIAPI SetWindowAdditionalData (HWND hWnd, DWORD newData)
 Set the first additional data of a window. More...
 
MG_EXPORT DWORD GUIAPI GetWindowAdditionalData2 (HWND hWnd)
 Retrieve the second additional data of a window. More...
 
MG_EXPORT DWORD GUIAPI SetWindowAdditionalData2 (HWND hWnd, DWORD newData)
 Set the second additional data of a window. More...
 
MG_EXPORT DWORD GUIAPI GetWindowClassAdditionalData (HWND hWnd)
 Retrieve the additional data of a control class. More...
 
MG_EXPORT DWORD GUIAPI SetWindowClassAdditionalData (HWND hWnd, DWORD newData)
 Set the additional data of a control class. More...
 
const MG_EXPORT char *GUIAPI GetWindowCaption (HWND hWnd)
 Retrieve the caption of a window. More...
 
MG_EXPORT BOOL GUIAPI SetWindowCaption (HWND hWnd, const char *spCaption)
 Set the caption of a window. More...
 
MG_EXPORT BOOL GUIAPI InvalidateRect (HWND hWnd, const RECT *prc, BOOL bEraseBkgnd)
 Makes a rectangle region in the client area of a window invalid. More...
 
MG_EXPORT BOOL GUIAPI InvalidateRegion (HWND hWnd, const CLIPRGN *pRgn, BOOL bErase)
 Invalidates the client area within the specified region. More...
 
MG_EXPORT BOOL GUIAPI ValidateRect (HWND hWnd, const RECT *rect)
 Validates the client area within a rectangle by removing the rectangle from the update region of the specified window. More...
 
MG_EXPORT BOOL GUIAPI ValidateRegion (HWND hWnd, const CLIPRGN *pRgn)
 Validates the client area within a region by removing the region from the current update region of the specified window. More...
 
MG_EXPORT HDC GUIAPI BeginPaint (HWND hWnd)
 Prepares a window for painting. More...
 
MG_EXPORT void GUIAPI EndPaint (HWND hWnd, HDC hdc)
 Marks the end of painting in a window. More...
 
MG_EXPORT BOOL GUIAPI GetUpdateRect (HWND hWnd, RECT *update_rect)
 Retrieve the bounding box of the update region of a window. More...
 
MG_EXPORT int GUIAPI GetUpdateRegion (HWND hWnd, PCLIPRGN pRgn)
 Copy the update region of a window to a region. More...
 
MG_EXPORT int GUIAPI ClientWidthToWindowWidthEx (DWORD dwStyle, int win_type, int cw)
 Calculates main window width from the width of the client area. More...
 
MG_EXPORT int GUIAPI ClientHeightToWindowHeightEx (DWORD dwStyle, int win_type, int ch, BOOL hasMenu)
 Calculates window height from the height of the client area. More...
 
MG_EXPORT BOOL GUIAPI AdjustWindowRectEx (RECT *pRect, DWORD dwStyle, BOOL bMenu, DWORD dwExStyle)
 Calculates the required size of the window rectangle based on the desired size of the client rectangle. More...
 
MG_EXPORT void GUIAPI ClientToScreen (HWND hWnd, int *x, int *y)
 Converts the client coordinates of a point to screen coordinates. More...
 
MG_EXPORT void GUIAPI ScreenToClient (HWND hWnd, int *x, int *y)
 Converts the screen coordinates of a point to client coordinates. More...
 
MG_EXPORT void GUIAPI ClientToWindow (HWND hWnd, int *x, int *y)
 Converts the client coordinates to the window coordinates. More...
 
MG_EXPORT void GUIAPI WindowToClient (HWND hWnd, int *x, int *y)
 Converts the window coordinates to client coordinates. More...
 
MG_EXPORT void GUIAPI WindowToScreen (HWND hWnd, int *x, int *y)
 Converts the window coordinates of a point to screen coordinates. More...
 
MG_EXPORT void GUIAPI ScreenToWindow (HWND hWnd, int *x, int *y)
 Converts the screen coordinates of a point to window coordinates. More...
 
MG_EXPORT BOOL GUIAPI IsMainWindow (HWND hWnd)
 Determine whether a window is a main window. More...
 
MG_EXPORT BOOL GUIAPI IsVirtualWindow (HWND hWnd)
 Determine whether a window is a virtual window. More...
 
MG_EXPORT BOOL GUIAPI IsControl (HWND hWnd)
 Determine whether a window is a control. More...
 
MG_EXPORT BOOL GUIAPI IsWindow (HWND hWnd)
 Determine whether a window handle identifies an existing window. More...
 
MG_EXPORT BOOL GUIAPI IsDialog (HWND hWnd)
 Determine whether a window handle identifies a dialog window. More...
 
MG_EXPORT HWND GUIAPI GetParent (HWND hWnd)
 Retrieve the handle to a child window's parent window. More...
 
MG_EXPORT HWND GUIAPI GetMainWindowHandle (HWND hWnd)
 Retrieve the handle to the main window contains a window. More...
 
MG_EXPORT BOOL GUIAPI IsWindowVisible (HWND hWnd)
 Retrieve the visibility state of the specified window. More...
 
MG_EXPORT BOOL GUIAPI GetWindowRect (HWND hWnd, PRECT prc)
 Retrieve the dimensions of the bounding rectangle of a window. More...
 
MG_EXPORT HWND GUIAPI GetNextChild (HWND hWnd, HWND hChild)
 Retrieve the next control in a window. More...
 
MG_EXPORT HWND GUIAPI GetNextMainWindow (HWND hMainWnd)
 Retrieve the next main window in the system according to the zorder. More...
 
MG_EXPORT HWND GUIAPI GetHostedById (HWND hHosting, LINT lId, DWORD dwSearchFlags)
 Retrieve a hosted main window or virtual window by identifier. More...
 
MG_EXPORT LINT GUIAPI GetWindowId (HWND hWnd)
 Get the identifier of a window. More...
 
MG_EXPORT LINT GUIAPI SetWindowId (HWND hWnd, LINT lNewId)
 Set the identifier of a window. More...
 
MG_EXPORT HWND GUIAPI GetRootWindow (int *nrWins)
 Retrieve the root window of the current thread. More...
 
MG_EXPORT HWND GUIAPI GetHosting (HWND hWnd)
 Retrieve the hosting window of a main window or a virtual window. More...
 
MG_EXPORT HWND GUIAPI GetFirstHosted (HWND hHosting)
 Retrieve the first hosted window of a main window or a virtual window. More...
 
MG_EXPORT HWND GUIAPI GetNextHosted (HWND hHosting, HWND hHosted)
 Retrieve the next hosted window of a main window or a virtual window. More...
 
MG_EXPORT int GUIAPI GetWindowTextLength (HWND hWnd)
 Retrieve the length of a window's text. More...
 
MG_EXPORT int GUIAPI GetWindowText (HWND hWnd, char *spString, int nMaxLen)
 Copies the text of a window's into a buffer. More...
 
MG_EXPORT BOOL GUIAPI SetWindowText (HWND hWnd, const char *spString)
 Set the text of a window. More...
 
MG_EXPORT HWND GUIAPI GetFocusChild (HWND hParent)
 Retrieve the handle to the window's active child that has the keyboard focus. More...
 
MG_EXPORT HWND GUIAPI SetNullFocus (HWND hParent)
 Cancels the current active child and set the focus child to be null. More...
 
MG_EXPORT HWND GUIAPI SetFocusChild (HWND hWnd)
 Set the active child of a window. More...
 
MG_EXPORT HWND GUIAPI GetActiveWindow (void)
 Retrieve the main window handle of the active main window. More...
 
MG_EXPORT HWND GUIAPI SetActiveWindow (HWND hMainWnd)
 Set a main window to be the active main window. More...
 
MG_EXPORT HWND GUIAPI GetCapture (void)
 Retrieve the handle to the window (if any) that has captured the mouse. More...
 
MG_EXPORT HWND GUIAPI SetCapture (HWND hWnd)
 Set the mouse capture to the specified window. More...
 
MG_EXPORT void GUIAPI ReleaseCapture (void)
 Releases the mouse capture from a window and restores normal mouse input processing. More...
 
MG_EXPORT HWND GUIAPI GetWindowUnderCursor (void)
 Retrieve the handle to the window (if any) which is just beneath the mouse cursor. More...
 
MG_EXPORT HWND GUIAPI WindowFromPointEx (POINT pt, BOOL bRecursion)
 Retrieve a handle to the window that contains the specified point. More...
 
MG_EXPORT HWND GUIAPI ChildWindowFromPointEx (HWND hParent, POINT pt, UINT uFlags)
 Retrieve a handle to the child window that contains the speicified point and meets the certain criteria. More...
 
static HWND GUIAPI ChildWindowFromPoint (HWND hParent, POINT pt)
 Retrieve a handle to the child window that contains the speicified point. More...
 
MG_EXPORT BOOL GUIAPI MoveWindow (HWND hWnd, int x, int y, int w, int h, BOOL fPaint)
 Changes the position and dimensions of a window. More...
 
MG_EXPORT int GUIAPI ScrollWindowEx (HWND hWnd, int dx, int dy, const RECT *prcScroll, const RECT *prcClip, PCLIPRGN pRgnUpdate, PRECT prcUpdate, UINT flags)
 Scrolls the content of a window's client area. More...
 
static void GUIAPI ScrollWindow (HWND hWnd, int dx, int dy, const RECT *prcScroll, const RECT *prcClip)
 Scrolls the content of a window's client area. More...
 

Detailed Description

Macro Definition Documentation

◆ GetFocus

#define GetFocus   GetFocusChild
See also
GetFocusChild

Definition at line 8806 of file window.h.

◆ GetForegroundWindow

#define GetForegroundWindow   GetActiveWindow
See also
GetActiveWindow

Definition at line 8840 of file window.h.

◆ GetWindowElementPixel

#define GetWindowElementPixel (   hWnd,
  iItem 
)    GetWindowElementPixelEx(hWnd, HDC_INVALID, iItem)

Get window element pixel value.

See also
GetWindowElementPixelEx

Definition at line 9131 of file window.h.

◆ SetFocus

#define SetFocus   SetFocusChild
See also
SetFocusChild

Definition at line 8800 of file window.h.

◆ SetForegroundWindow

#define SetForegroundWindow   SetActiveWindow
See also
SetActiveWindow

Definition at line 8846 of file window.h.

Function Documentation

◆ AdjustWindowRectEx()

BOOL AdjustWindowRectEx ( RECT pRect,
DWORD  dwStyle,
BOOL  bMenu,
DWORD  dwExStyle 
)

Calculates the required size of the window rectangle based on the desired size of the client rectangle.

This function calculates the required size of the window rectangle, based on the desired size of the client rectangle. The window rectangle can then be passed to the CreateMainWindow or CreateWindow function to create a window whose client area is the desired size.

A client rectangle is the smallest rectangle that completely encloses a client area. A window rectangle is the smallest rectangle that completely encloses the window, which includes the client area and the nonclient area.

The AdjustWindowRectEx function does not add extra space when a menu bar wraps to two or more rows.

The AdjustWindowRectEx function takes the WS_VSCROLL or WS_HSCROLL styles into account.

Parameters
pRectPointer to a RECT structure that contains the coordinates of the top-left and bottom-right corners of the desired client area. When the function returns, the structure contains the coordinates of the top-left and bottom-right corners of the window to accommodate the desired client area.
dwStyleSpecifies the window style of the window whose required size is to be calculated.
bMenuSpecifies whether the window has a menu.
dwExStyleSpecifies the extended window style of the window whose required size is to be calculated.
Returns
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
See also
ClientWidthToWindowWidth, ClientHeightToWindowHeight

◆ BeginPaint()

HDC GUIAPI BeginPaint ( HWND  hWnd)

Prepares a window for painting.

This function prepares the specified window hWnd for painting. This function is called in the handler of MSG_PAINT message normally. It returns a device context including the update region of the window. When you are done with the device context, you should call EndPaint to finish the painting of the window.

Parameters
hWndThe handle to the window.
Returns
The device context.
See also
EndPaint

◆ ChildWindowFromPoint()

HWND GUIAPI ChildWindowFromPoint ( HWND  hParent,
POINT  pt 
)
inlinestatic

Retrieve a handle to the child window that contains the speicified point.

This function determines which, if any, of the child windows belonging to a parent window contains the specified point by calling ChildWindowFromPointEx and passing CWP_ALL to uFlags parameter.

See also
ChildWindowFromPointEx

Definition at line 8981 of file window.h.

◆ ChildWindowFromPointEx()

HWND GUIAPI ChildWindowFromPointEx ( HWND  hParent,
POINT  pt,
UINT  uFlags 
)

Retrieve a handle to the child window that contains the speicified point and meets the certain criteria.

This function determines which, if any, of the child windows belonging to a parent window contains the specified point. The function can ignore invisible, disabled, and transparent child windows. The search is restricted to immediate child windows. Grandchildren, and deeper descendant windows are not searched.

Parameters
hParentHandle to the parent window.
ptSpecifies a POINT structure that defines the client coordinates (relative to hParent) of the point to be checked.
uFlagsSpecifies which child windows to skip. This parameter can be one or more of the following values.
  • CWP_ALL
    Does not skip any child windows
  • CWP_SKIPINVISIBLE
    Skips invisible child windows
  • CWP_SKIPDISABLED
    Skips disabled child windows
  • CWP_SKIPTRANSPARENT
    Skips transparent child windows
Returns
The return value is a handle to the first child window that contains the point and meets the criteria specified by uFlags. If the point is within the parent window but not within any child window that meets the criteria, the return value is a handle to the parent window. If the point lies outside the parent window or if the function fails, the return value is HWND_NULL.
See also
ChildWindowFromPoint

◆ ClientHeightToWindowHeightEx()

int GUIAPI ClientHeightToWindowHeightEx ( DWORD  dwStyle,
int  win_type,
int  ch,
BOOL  hasMenu 
)

Calculates window height from the height of the client area.

This function calculates the main window height from the height of the client area.

Parameters
dwStyleThe style of window.
win_typeThe type of window.
chThe height of the client area.
hasMenuIndicates whether the main window has menu.
Returns
The height of the main window.
See also
ClientWidthToWindowWidthEx

◆ ClientToScreen()

void GUIAPI ClientToScreen ( HWND  hWnd,
int *  x,
int *  y 
)

Converts the client coordinates of a point to screen coordinates.

This function converts the client coordinates of the specified point (*x,*y) in the specified window hWnd to screen coordinates.

Parameters
hWndThe handle to the window.
xThe pointer to the x coordinate.
yThe pointer to the y coordinate.
See also
ScreenToClient

◆ ClientToWindow()

void GUIAPI ClientToWindow ( HWND  hWnd,
int *  x,
int *  y 
)

Converts the client coordinates to the window coordinates.

This function converts the client coordinates of the specified point (*x,*y) in the specified window hWnd to the window coordinates.

Parameters
hWndThe handle to the window.
xThe pointer to the x coordinate.
yThe pointer to the y coordinate.
See also
WindowToClient

◆ ClientWidthToWindowWidthEx()

int GUIAPI ClientWidthToWindowWidthEx ( DWORD  dwStyle,
int  win_type,
int  cw 
)

Calculates main window width from the width of the client area.

This function calculates the window width from the width of the client area.

Parameters
dwStyleThe style of window.
win_typeThe type of window.
cwThe width of the client area.
Returns
The width of the main window.
See also
ClientHeightToWindowHeightEx

◆ DWORD2PixelByWindow()

gal_pixel GUIAPI DWORD2PixelByWindow ( HWND  hWnd,
DWORD  dwColor 
)

Convert a DWORD color to gal_pixel for a window.

This function converts a color in DWORD to the pixel value according to the surface of the main window.

Parameters
hWndThe handle to the window.
dwColorThe color value in DWORD.
Returns
The converted pixel value.

◆ EnableWindow()

BOOL GUIAPI EnableWindow ( HWND  hWnd,
BOOL  fEnable 
)

Enables of disables a window.

This function enables or disables mouse and keyboard input to the specified window hWnd. When input is disabled, the window does not receive input such as mouse clicks and key presses. When input is enabled, the window receives all input.

Parameters
hWndThe handle to the window.
fEnableIndicates whether to enable or disable the window, TRUE for enable.
Returns
The old enable state of the window.
See also
IsWindowEnabled

◆ EndPaint()

void GUIAPI EndPaint ( HWND  hWnd,
HDC  hdc 
)

Marks the end of painting in a window.

This function marks the end of painting in the specified window. This function is required for each call to the BeginPaint function, but only after painting is complete.

Parameters
hWndThe handle to the window.
hdcThe device context returned by BeginPaint.
See also
BeginPaint

◆ ExcludeWindowExStyle()

BOOL GUIAPI ExcludeWindowExStyle ( HWND  hWnd,
DWORD  dwStyle 
)

Removes the specific extended style of a window.

This function removes the specific extended style of the window specified by hWnd.

Note that you should be very careful with changing the extended styles of a window on the fly by calling this function. You are strongly recommended to only change the customizable window styles (bits in WS_EX_CONTROL_MASK | WS_EX_CONTROL_MASK) by calling this function.

Parameters
hWndThe handle to the window.
dwStyleThe specific extended style which will be removed.
Returns
TRUE on success, otherwise FALSE.
See also
ExcludeWindowStyle

◆ ExcludeWindowStyle()

BOOL GUIAPI ExcludeWindowStyle ( HWND  hWnd,
DWORD  dwStyle 
)

Removes the specific style of a window.

This function removes the specific style of the window specified by hWnd.

Note that you should be very careful with changing the styles of a window on the fly by calling this function. You are strongly recommended to only change the customizable window styles (bits in WS_CTRLMASK) by calling this function.

Parameters
hWndThe handle to the window.
dwStyleThe specific style which will be removed.
Returns
TRUE on success, otherwise FALSE.
See also
ExcludeWindowStyle

◆ GetActiveWindow()

HWND GUIAPI GetActiveWindow ( void  )

Retrieve the main window handle of the active main window.

This function retrieves the main window handle of the active main window which receives the input.

Returns
The handle to the active main window.
See also
SetActiveWindow, GetFocusChild

◆ GetCapture()

HWND GUIAPI GetCapture ( void  )

Retrieve the handle to the window (if any) that has captured the mouse.

This function retrieves the handle to the window (if any) that has captured the mouse. Only one window at a time can capture the mouse; this window receives mouse input whether or not the cursor is within its borders.

Returns
The handle to the window that has captured the mouse, 0 for no window captures the mouse.
See also
SetCapture

◆ GetClientRect()

BOOL GUIAPI GetClientRect ( HWND  hWnd,
PRECT  prc 
)

Retrieve the client rectangle of a window.

This function retrieves the coordinates of the client area of the window specified by hWnd. The client coordinates specify the upper-left and lower-right corners of the client area. Because client coordinates are relative to the upper-left corner of a window's client area, the coordinates of the upper-left corner are always (0,0).

Parameters
hWndThe handle to the window.
prcThe pointer to a RECT structure receives the client rectangle.
Returns
TRUE on sucess, otherwise FALSE.
Note
Note that the coordinates of the upper-left corner are always zero.
See also
MoveWindow

◆ GetFirstHosted()

HWND GUIAPI GetFirstHosted ( HWND  hHosting)

Retrieve the first hosted window of a main window or a virtual window.

All main windows and/or virtual windows in a thread form a window tree. The root window of the tree may be HWND_DESKTOP or the first main/virtual window created in the thread.

This function retrieves the first hosted main/virtual window of the specified main window hMainWnd.

Parameters
hHostingThe handle to a main window or a virtual window.
Returns
The handle to the first hosted window. If an invalid window handle is passed for hHosting, HWND_INVALID will be returned. If the specified window do not have a hosted window, this function returns HWND_NULL.
See also
GetHosting, GetNextHosted

◆ GetFocusChild()

HWND GUIAPI GetFocusChild ( HWND  hParent)

Retrieve the handle to the window's active child that has the keyboard focus.

This function retrieves the handle to the window's active child that has the keyboard focus.

Parameters
hParentThe handle to the parent window.
Returns
The handle to the active child.
See also
SetFocusChild, SetNullFoucs

◆ GetHostedById()

HWND GUIAPI GetHostedById ( HWND  hHosting,
LINT  lId,
DWORD  dwSearchFflags 
)

Retrieve a hosted main window or virtual window by identifier.

All main windows and/or virtual windows in a thread form a window tree. The root window of the tree may be HWND_DESKTOP or the first main/virtual window created in the thread.

This function retrieves the first window which has the specified identifier id in the window tree of the current thread.

Parameters
hHostingThe handle to a main or virtual window in the thread, which will be the root of the sub window tree to search. If it is HWND_NULL, this function will use the root window of the current thread.
lIdThe identifier.
dwSearchFflagsThe search flags, should be OR'd with a search method value and one or two search filter values:
  • WIN_SEARCH_METHOD_BFS
    use BFS (breadth-first search).
  • WIN_SEARCH_METHOD_DFS
    use DFS (depth-first search).
  • WIN_SEARCH_FILTER_MAIN
    search main windows.
  • WIN_SEARCH_FILTER_VIRT
    search virtual windows.
Returns
The handle to the first main window or virtual window which has the specified identifier in the searching sub window tree. If the current thread is not a message thread, it returns HWND_INVALID. If there is no window matches the identifier and the search flags, it returns HWND_NULL.
See also
GetRootWindow, GetHosting, GetFirstHosted, GetNextHosted

◆ GetHosting()

HWND GUIAPI GetHosting ( HWND  hWnd)

Retrieve the hosting window of a main window or a virtual window.

All main windows and/or virtual windows created by a thread form a window hosting tree. The root window of the tree may be HWND_DESKTOP or the first main/virtual window created by the thread.

This function retrieves the hosting window of the specified main window or virtual window hWnd.

For a root window in the current thread, this function returns HWND_NULL.

Parameters
hWndThe handle to the main window.
Returns
The handle to the hosting window. If error occurs, for example, an invalid handle, the specified window is not in the current thread, or the current thread is not a message thread, this function returns HWND_INVALID. For a root window in the current thread, this function returns HWND_NULL.
See also
GetRootWindow, GetFirstHosted, GetNextHosted

◆ GetMainWindowHandle()

HWND GUIAPI GetMainWindowHandle ( HWND  hWnd)

Retrieve the handle to the main window contains a window.

This function retrieves the handle to the main window which contains the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The handle to the main window, HWND_INVALID indicates an error.
Note
For a main window, this function always returns the handle to itself. For HWND_DESKTOP, HWND_DESKTOP is returned.
See also
GetParent

◆ GetNextChild()

HWND GUIAPI GetNextChild ( HWND  hWnd,
HWND  hChild 
)

Retrieve the next control in a window.

This function retrieves the next child of the specified window hWnd. If you pass HWND_NULL for the argument of hChild, the function will return the first child of the window.

Parameters
hWndThe handle to the window.
hChildThe handle to a child of the window.
Returns
The handle of the next child. If you pass HWND_NULL for the argument of hChild, it will return the first child of the window. When the child you passed is the last one, this function will return HWND_NULL. If hWnd is not the parent of hChild, this function will return HWND_INVALID.
See also
GetNextMainWindow
Note
Do not use HWND_DESKTOP for hWnd or hChild.

Example:

/*
* Sample code for GetNextChild:
* Travles all child of a window \a hWnd.
*/
do {
child = GetNextChild (hWnd, child);
} while (child != HWND_DESKTOP);

◆ GetNextHosted()

HWND GUIAPI GetNextHosted ( HWND  hHosting,
HWND  hHosted 
)

Retrieve the next hosted window of a main window or a virtual window.

All main windows and/or virtual windows in a thread form a window tree. The root window of the tree may be HWND_DESKTOP or the first main/virtual window created in the thread.

This function retrieves the next hosted main/virtual window of the specified main/virtual window hHosting. If hHosted is HWND_NULL, it is equivalent to call GetFirstHosted(hHosting).

Parameters
hHostingThe handle to the hosting window.
hHostedThe handle to a known hosted window. This function will return the next hosted window.
Returns
The handle to the next hosted main or virtual window. It returns HWND_NULL when hHosted is the last hosted window. If invalid window handles are passed, or if hHosted is not a hosted window of hHosting, this function returns HWND_INVALID.
See also
GetHosting, GetFirstHosted

◆ GetNextMainWindow()

HWND GUIAPI GetNextMainWindow ( HWND  hMainWnd)

Retrieve the next main window in the system according to the zorder.

This function retrieves the next main window of the specified main window hMainWnd.

Parameters
hMainWndThe handle to the main window.
Returns
The handle of the next main window. If you pass HWND_NULL for the argument of hMainWnd, it will return the topmost main window. When the main window you passed is the bottommost one, this function will return HWND_NULL. If hMainWnd is not a main window, the function will return HWND_INVALID.
See also
GetNextChild

◆ GetParent()

HWND GUIAPI GetParent ( HWND  hWnd)

Retrieve the handle to a child window's parent window.

This function retrieves the handle to the specified child window's parent window.

Parameters
hWndThe handle to the child window.
Returns
The handle to the parent, HWND_INVALID indicates an error.
Note
For a main window, this function always returns HWNL_NULL. For HWND_DESKTOP or an invalid window handle, HWND_INVALID will be returned.
See also
GetMainWindowHandle

◆ GetRootWindow()

HWND GUIAPI GetRootWindow ( int *  nrWins)

Retrieve the root window of the current thread.

All main windows and/or virtual windows in a thread form a window tree. The root window of the tree may be HWND_DESKTOP or the first main/virtual window created in the thread.

This function retrieves and returns the root window in the current thread.

Parameters
nrWinsA pointer to an integer used to return the number of total windows in the current thread. It can be NULL.
Returns
The handle to the root window. If the current thread is not a message thread, it returns HWND_INVALID. If there is no any window created in the current thread, it returns HWND_NULL.
See also
GetHosting, GetFirstHosted, GetNextHosted, GetMainWindowById

◆ GetUpdateRect()

BOOL GUIAPI GetUpdateRect ( HWND  hWnd,
RECT update_rect 
)

Retrieve the bounding box of the update region of a window.

This function retrieves the bounding box of the update region of the specified window hWnd.

Parameters
hWndThe handle to the window.
update_rectThe pointer to a RECT structure which will contains the bounding box of the update region.
Returns
TRUE on success, otherwise FALSE.
See also
InvalidateRect

◆ GetUpdateRegion()

int GUIAPI GetUpdateRegion ( HWND  hWnd,
PCLIPRGN  pRgn 
)

Copy the update region of a window to a region.

This function copies the update region of the specified window hWnd into the region pRgn.

Parameters
hWndThe handle to the window.
pRgnThe pointer to a region which receives the update region of the window.
Returns
The region type.
Return values
NULLREGIONRegion is empty.
SIMPLEREGIONRegion is a single rectangle.
COMPLEXREGIONRegion is more than one rectangle.
-1An error occurred.
See also
GetUpdateRect

◆ GetWindowAdditionalData()

DWORD GUIAPI GetWindowAdditionalData ( HWND  hWnd)

Retrieve the first additional data of a window.

This function retrieves the first additional data of the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The first additional data of the window.
See also
SetWindowAdditionalData

◆ GetWindowAdditionalData2()

DWORD GUIAPI GetWindowAdditionalData2 ( HWND  hWnd)

Retrieve the second additional data of a window.

This function retrieves the second additional data of the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The second additional data of the window.
See also
SetWindowAdditionalData2

◆ GetWindowBkColor()

gal_pixel GUIAPI GetWindowBkColor ( HWND  hWnd)

Returns the current background color of a window.

This function returns the pixel value of the current background color of the window specified by hWnd.

Parameters
hWndThe handle to the window.
Returns
The pixel value of the background color.
Note
The type of return value changed from int to gal_pixel since v3.2.
See also
SetWindowBkColor

◆ GetWindowCallbackProc()

WNDPROC GUIAPI GetWindowCallbackProc ( HWND  hWnd)

Retrieve the callback procedure of a window.

This function retrieves the window callback procedure of the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The callback procedure of the window.
See also
SetWindowCallbackProc

◆ GetWindowCaption()

const char *GUIAPI GetWindowCaption ( HWND  hWnd)

Retrieve the caption of a window.

This function retrieves the caption of the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The pointer to the caption string of the window.
See also
SetWindowCaption

◆ GetWindowClassAdditionalData()

DWORD GUIAPI GetWindowClassAdditionalData ( HWND  hWnd)

Retrieve the additional data of a control class.

This function retrieves the additional data of the control class to which the specified control hWnd belongs.

Parameters
hWndThe handle to the control.
Returns
The additional data of the control class to which the control belongs.
Note
Note that this function always returns zero for the main window.
See also
SetWindowClassAdditionalData

◆ GetWindowCursor()

HCURSOR GUIAPI GetWindowCursor ( HWND  hWnd)

Retrieve the current cursor of a window.

This function retrieves the current cursor of the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The handle to the cursor.
See also
SetWindowCursor

◆ GetWindowExStyle()

DWORD GUIAPI GetWindowExStyle ( HWND  hWnd)

Retrieve the extended style of a window.

This function retrieves the extended style of the window specified by hWnd.

Parameters
hWndThe handle to the window.
Returns
The extended style of the window.
See also
GetWindowStyle

◆ GetWindowFont()

PLOGFONT GUIAPI GetWindowFont ( HWND  hWnd)

Retrieve the default font of a window.

This function retrieves the default font of the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The default logical font of the window.
See also
SetWindowFont

◆ GetWindowIcon()

HICON GUIAPI GetWindowIcon ( HWND  hWnd)

Retrieve the current icon of a window.

This function retrieves the current icon of the specified window hWnd.

Parameters
hWndThe handle to the window.
Returns
The handle to the icon.
See also
SetWindowIcon

◆ GetWindowId()

LINT GUIAPI GetWindowId ( HWND  hWnd)

Get the identifier of a window.

This function returns the identifier of the specified window hWnd.

Returns
The identifier of the window. This function returns -1 for an invalid window handle. Therefore, you should avoid to use -1 as a valid identifier of a window.
See also
SetWindowId

◆ GetWindowRect()

BOOL GUIAPI GetWindowRect ( HWND  hWnd,
PRECT  prc 
)

Retrieve the dimensions of the bounding rectangle of a window.

This function retrieves the dimension of the bounding rectangle of the specified window hWnd. The dimensions are given in parent's client coordinates (screen coordinates for main window) that are relative to the upper-left corner of the parent's client area (screen).

Parameters
hWndThe handle to the window.
prcThe pointer to a RECT structure which will contains the window rectangle.
Returns
TRUE on success, otherwise FALSE.
See also
GetClientRect

◆ GetWindowStyle()

DWORD GUIAPI GetWindowStyle ( HWND  hWnd)

Retrieve the style of a window.

This function retrieves the style of the window specified by hWnd.

Parameters
hWndThe handle to the window.
Returns
The style of the window.
See also
GetWindowExStyle

◆ GetWindowText()

int GUIAPI GetWindowText ( HWND  hWnd,
char *  spString,
int  nMaxLen 
)

Copies the text of a window's into a buffer.

This function copies the text of the specified window hWnd into the buffer pointed to by spString. The function gets the window text by sending an MSG_GETTEXT message to the window.

Parameters
hWndThe handle to the window.
spStringThe pointer to a buffer receives the text.
nMaxLenThe maximal number of characters can be copied to the buffer.
Returns
The length of the window text string.
See also
GetWindowCaption, SetWindowText

◆ GetWindowTextLength()

int GUIAPI GetWindowTextLength ( HWND  hWnd)

Retrieve the length of a window's text.

This function retrieves the length, in characters, of the specified window's text. The function retrieves the length of the text by sending an MSG_GETTEXTLENGTH message to the window.

Parameters
hWndThe handle to the window.
Returns
The length of the window's text.
See also
GetWindowText

◆ GetWindowUnderCursor()

HWND GUIAPI GetWindowUnderCursor ( void  )

Retrieve the handle to the window (if any) which is just beneath the mouse cursor.

This function retrieves the handle to the window (if any) that is under the mouse cursor. If a parent window and a child window are all under the mouse cursor, the handle to the child window will be returned.

Returns
The handle to the window under the mouse cursor, HWND_NULL for no window is under the mouse cursor.

◆ IncludeWindowExStyle()

BOOL GUIAPI IncludeWindowExStyle ( HWND  hWnd,
DWORD  dwStyle 
)

Includes the specific extended style of a window.

This function includes the specific extended style of the window specified by hWnd.

Note that you should be very careful with changing the extended styles of a window on the fly by calling this function. You are strongly recommended to only change the customizable window styles (bits in WS_EX_CONTROL_MASK | WS_EX_CONTROL_MASK) by calling this function.

Parameters
hWndThe handle to the window.
dwStyleThe specific extended style which will be included.
Returns
TRUE on success, otherwise FALSE.
See also
IncludeWindowStyle

◆ IncludeWindowStyle()

BOOL GUIAPI IncludeWindowStyle ( HWND  hWnd,
DWORD  dwStyle 
)

Includes the specific style of a window.

This function includes the specific style of the window specified by hWnd.

Note that you should be very careful with changing the styles of a window on the fly by calling this function. You are strongly recommended to only change the customizable window styles (bits in WS_CTRLMASK) by calling this function.

Parameters
hWndThe handle to the window.
dwStyleThe specific style which will be included.
Returns
TRUE on success, otherwise FALSE.
See also
IncludeWindowStyle

◆ InvalidateRect()

BOOL GUIAPI InvalidateRect ( HWND  hWnd,
const RECT prc,
BOOL  bEraseBkgnd 
)

Makes a rectangle region in the client area of a window invalid.

This function adds a rectangle pointed to by prc to the specified window's update region. The update region represents the portion of the window's client area that must be redrawn, and erase background if argument bReaseBkgnd is set.

Parameters
hWndThe handle to the window.
prcThe pointer to a RECT structure which defines the invalid rectangle.
bEraseBkgndIndicates whether the background should be erased.
Returns
TRUE on success, otherwise FALSE.
See also
MSG_PAINT

◆ InvalidateRegion()

BOOL GUIAPI InvalidateRegion ( HWND  hWnd,
const CLIPRGN pRgn,
BOOL  bErase 
)

Invalidates the client area within the specified region.

This function invalidates the client area within the specified region by adding it to the current update region of a window. The invalidated region, along with all other areas in the update region, is marked for painting when the next MSG_PAINT message occurs.

Parameters
hWndHandle to the window with an update region that is to be modified.
pRgnPointer to the region to be added to the update region. The region is assumed to have client coordinates. If this parameter is NULL, the entire client area is added to the update region.
bEraseSpecifies whether the background within the update region should be erased when the update region is processed. If this parameter is TRUE, the background is erased. If the parameter is FALSE, the background remains unchanged.
Returns
TRUE on success, otherwise FALSE.
Note
Invalidated areas accumulate in the update region until the next MSG_PAINT message is processed or until the region is validated by using the ValidateRect or ValidateRegion function. MiniGUI sends a MSG_PAINT message to a window whenever its update region is not empty and there are no other messages in the application queue for that window. The specified region must have been created by using one of the region functions. If the bErase parameter is TRUE for any part of the update region, the background in the entire region is erased, not just in the specified part.
See also
MSG_PAINT, InvalidateRect, ValidateRegion

◆ IsControl()

BOOL GUIAPI IsControl ( HWND  hWnd)

Determine whether a window is a control.

This function determines whether the specified window hWnd is a control.

Parameters
hWndThe handle to the window.
Returns
TRUE for control, otherwise FALSE.
See also
IsMainWindow, IsWindow

◆ IsDialog()

BOOL GUIAPI IsDialog ( HWND  hWnd)

Determine whether a window handle identifies a dialog window.

This function determines whether the specified window handle hWnd identifies a dialog window.

Parameters
hWndThe window handle.
Returns
TRUE for dialog window, otherwise FALSE.
See also
IsMainWindow, IsControl

◆ IsMainWindow()

BOOL GUIAPI IsMainWindow ( HWND  hWnd)

Determine whether a window is a main window.

This function determines whether the specified window hWnd is a main window or not.

Parameters
hWndThe handle to the window.
Returns
TRUE for main window, otherwise FALSE.
See also
IsControl, IsWindow

◆ IsVirtualWindow()

BOOL GUIAPI IsVirtualWindow ( HWND  hWnd)

Determine whether a window is a virtual window.

This function determines whether the specified window hWnd is a virtual window or not.

Parameters
hWndThe handle to the window.
Returns
TRUE for a virtual window, otherwise FALSE.
See also
IsMainWindow, IsWindow, IsControl

◆ IsWindow()

BOOL GUIAPI IsWindow ( HWND  hWnd)

Determine whether a window handle identifies an existing window.

This function determines whether the specified window handle hWnd identifies an existing window.

Parameters
hWndThe window handle.
Returns
TRUE for window, otherwise FALSE.
See also
IsMainWindow, IsControl

◆ IsWindowEnabled()

BOOL GUIAPI IsWindowEnabled ( HWND  hWnd)

Determine whether the specified window is enabled for mouse and keyboard input.

This function returns the enable/disable state of the window specified by hWnd.

Parameters
hWndThe handle to the window.
Returns
The enable/disable state of the window, TRUE for enabled.
See also
EnableWindow

◆ IsWindowVisible()

BOOL GUIAPI IsWindowVisible ( HWND  hWnd)

Retrieve the visibility state of the specified window.

This function retrieves the visibility state of the specified window hWnd.

Parameters
hWndHandle to the window to test.
Returns
If the specified window, its parent window, its parent's parent window, and so forth, all have the WS_VISIBLE style, the return value is nonzero. Otherwise the return value is zero.
See also
ShowWindow

◆ MoveWindow()

BOOL GUIAPI MoveWindow ( HWND  hWnd,
int  x,
int  y,
int  w,
int  h,
BOOL  fPaint 
)

Changes the position and dimensions of a window.

This function changes the position and dimensions of the specified window hWnd. For a main window, the position and dimensions are relative to the upper-left corner of the screen. For a control, they are relative to the upper-left corner of the parent window's client area.

Parameters
hWndThe handle to the window.
xThe new x coordinate of the upper-left corner of the window.
yThe new y coordinate of the upper-left corner of the window.
wThe new width of the window.
hThe new height of the window.
fPaintIndicates whether the window should be repainted.
Returns
TRUE on success, otherwise FALSE.
See also
ScrollWindow

◆ ReleaseCapture()

void GUIAPI ReleaseCapture ( void  )

Releases the mouse capture from a window and restores normal mouse input processing.

This function releases the mouse capture from a window and restores normal mouse input processing. A window that has captured the mouse receives all mouse input, regardless of the position of the cursor.

See also
GetCapture, SetCapture

◆ ScreenToClient()

void GUIAPI ScreenToClient ( HWND  hWnd,
int *  x,
int *  y 
)

Converts the screen coordinates of a point to client coordinates.

This function converts the screen coordinates of the specified point (*x,*y) to client coordinates of the specified window hWnd.

Parameters
hWndThe handle to the window.
xThe pointer to the x coordinate.
yThe pointer to the y coordinate.
See also
ClientToScreen

◆ ScreenToWindow()

void GUIAPI ScreenToWindow ( HWND  hWnd,
int *  x,
int *  y 
)

Converts the screen coordinates of a point to window coordinates.

This function converts the screen coordinates of the specified point (*x,*y) to the window coordinates of the specfied window hWnd.

Parameters
hWndThe handle to the window.
xThe pointer to the x coordinate.
yThe pointer to the y coordinate.
See also
WindowToScreen

◆ ScrollWindow()

void GUIAPI ScrollWindow ( HWND  hWnd,
int  dx,
int  dy,
const RECT prcScroll,
const RECT prcClip 
)
inlinestatic

Scrolls the content of a window's client area.

This function scrolls the content of the specified window's client area.

Parameters
hWndThe handle to the window.
dxThe new x coordinate of the origin in the client coordinates system after scrolling.
dyThe new y coordinate of the origin in the client coordinates system after scrolling.
prcScrollThe rectangle of the area which will be scrolled actually. NULL for whole client area.
prcClipA rectangle, all children covered totally by this rectangle will be moved after scrolling. All of the children will be moved if prcClip is NULL.
See also
MoveWindow

Definition at line 9109 of file window.h.

◆ ScrollWindowEx()

int GUIAPI ScrollWindowEx ( HWND  hWnd,
int  dx,
int  dy,
const RECT prcScroll,
const RECT prcClip,
PCLIPRGN  pRgnUpdate,
PRECT  prcUpdate,
UINT  flags 
)

Scrolls the content of a window's client area.

This function scrolls the content of a window's client area.

If the SW_INVALIDATE and SW_ERASE flags are not specified, ScrollWindowEx does not invalidate the area that is scrolled from. If either of these flags is set, ScrollWindowEx invalidates this area. The area is not updated until the application calls the UpdateWindow function or retrieves the MSG_PAINT message from the application queue.

If the window has the WS_CLIPCHILDREN style, the returned areas specified by pRgnUpdate and prcUpdate represent the total area of the scrolled window that must be updated, including any areas in child windows that need updating.

If the SW_SCROLLCHILDREN flag is specified, the system does not properly update the screen if part of a child window is scrolled. The part of the scrolled child window that lies outside the source rectangle is not erased and is not properly redrawn in its new destination. To move child windows that do not lie completely within the rectangle specified by prcScroll, use the DeferWindowPos function. The cursor is repositioned if the SW_SCROLLCHILDREN flag is set and the caret rectangle intersects the scroll rectangle.

All input and output coordinates (for prcScroll, prcClip, prcUpdate, and pRgnUpdate) are determined as client coordinates.

Parameters
hWndHandle to the window where the client area is to be scrolled.
dxSpecifies the amount, in device units, of horizontal scrolling. This parameter must be a negative value to scroll to the left.
dySpecifies the amount, in device units, of vertical scrolling. This parameter must be a negative value to scroll up.
prcScrollPointer to a RECT structure that specifies the portion of the client area to be scrolled. If this parameter is NULL, the entire client area is scrolled.
prcClipPointer to a RECT structure that contains the coordinates of the clipping rectangle. Only device bits within the clipping rectangle are affected. Bits scrolled from the outside of the rectangle to the inside are painted; bits scrolled from the inside of the rectangle to the outside are not painted. This parameter may be NULL.
pRgnUpdatePointer to the region that is modified to hold the region invalidated by scrolling. This parameter may be NULL.
prcUpdatePointer to a RECT structure that receives the boundaries of the rectangle invalidated by scrolling. This parameter may be NULL.
flagsSpecifies flags that control scrolling. This parameter can be one of the following values:
  • SW_ERASE
    Erases the newly invalidated region by sending a MSG_ERASEBKGND message to the window when specified with the SW_INVALIDATE flag.
  • SW_INVALIDATE
    Invalidates the region identified by the pRgnUpdate parameter after scrolling.
  • SW_SCROLLCHILDREN
    Scrolls all child windows that intersect the rectangle pointed to by the prcScroll parameter. The child windows are scrolled by the number of pixels specified by the dx and dy parameters. MiniGUI calls MoveWindow to all child windows that intersect the prcScroll rectangle, even if they do not move.
Returns
If the function succeeds, the return value is SIMPLEREGION (rectangular invalidated region), COMPLEXREGION (nonrectangular invalidated region; overlapping rectangles), or NULLREGION (no invalidated region). If the function fails, the return value is -1.

◆ SetActiveWindow()

HWND GUIAPI SetActiveWindow ( HWND  hMainWnd)

Set a main window to be the active main window.

This function sets the specified main window hMainWnd to be the active main window which receives the input.

Parameters
hMainWndThe handle to the new active main window.
Returns
The handle to the old active main window.
See also
GetActiveWindow, SetFocusChild

◆ SetCapture()

HWND GUIAPI SetCapture ( HWND  hWnd)

Set the mouse capture to the specified window.

This function sets the mouse capture to the specified window hWnd. Once a window has captured the mouse, all mouse input is directed to that window, regardless of whether the cursor is within the borders of that window. Only one window at a time can capture the mouse.

Parameters
hWndThe handle to the window.
Returns
The old capture window.
See also
GetCapture

◆ SetFocusChild()

HWND GUIAPI SetFocusChild ( HWND  hWnd)

Set the active child of a window.

This function sets the specified window hWnd as the active child of its parent.

Parameters
hWndThe handle to the window.
Returns
The handle to the old active child of its parent.
See also
GetFocusChild, SetNullFocus

◆ SetNullFocus()

HWND GUIAPI SetNullFocus ( HWND  hParent)

Cancels the current active child and set the focus child to be null.

This function cancels the current active child and set the focus child of the window hParent to be null.

Parameters
hParentThe handle to the parent window.
Returns
The handle to the old active child.
See also
GetFocusChild, SetFocusChild

◆ SetWindowAdditionalData()

DWORD GUIAPI SetWindowAdditionalData ( HWND  hWnd,
DWORD  newData 
)

Set the first additional data of a window.

This function sets the first additional data of the specified window hWnd.

Parameters
hWndThe handle to the window.
newDataThe new first additional data of the window.
Returns
The old first additional data of the window.
Note
For a dialog box created by DialogBoxIndirectParam, its second additional data used internally by the system to save the return value of the box. So you should avoid setting the second additional data of a dialog box.
See also
GetWindowAdditionalData

◆ SetWindowAdditionalData2()

DWORD GUIAPI SetWindowAdditionalData2 ( HWND  hWnd,
DWORD  newData 
)

Set the second additional data of a window.

This function sets the second additional data of the specified window hWnd.

Parameters
hWndThe handle to the window.
newDataThe new second additional data of the window.
Returns
The old second additional data of the window.
Note
For a control created by CreateWindowEx, its second additional data is reserved for internal use. So you should avoid setting the second additional data of a control.
See also
GetWindowAdditionalData2

◆ SetWindowBkColor()

gal_pixel GUIAPI SetWindowBkColor ( HWND  hWnd,
gal_pixel  new_bkcolor 
)

Set the background color of a window.

This function sets the background color of the specified window hWnd to be new pixel value new_backcolor. You should call UpdateWindow or InvalidateRect in order that the new background color runs into affect.

Parameters
hWndThe handle to the window.
new_bkcolorThe pixel value of the new background color.
Returns
The pixel value of the old background color.
Note
The type of return value and new_bkcolor changed from int to gal_pixel since v3.2.
See also
GetWindowBkColor

◆ SetWindowCallbackProc()

WNDPROC GUIAPI SetWindowCallbackProc ( HWND  hWnd,
WNDPROC  newProc 
)

Set the callback procedure of a window.

This function sets the window callback procedure of the specified window hWnd to be the procedure newProc.

Parameters
hWndThe handle to the window.
newProcThe new callback procedure of the window.
Returns
The old callback procedure of the window.
See also
GetWindowCallbackProc

Example:

/*
* The following code uses SetWindowCallbackProc function to
* change the default window callback procedures of some controls.
*/
#define IDC_CTRL1 100
#define IDC_CTRL2 110
#define IDC_CTRL3 120
#define IDC_CTRL4 130
#define MY_ES_DIGIT_ONLY 0x0001
#define MY_ES_ALPHA_ONLY 0x0002
static WNDPROC old_edit_proc;
static LRESULT RestrictedEditBox (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
if (message == MSG_CHAR) {
DWORD my_style = GetWindowAdditionalData (hwnd);
/* Determine whether the character should be masked. */
if ((my_style & MY_ES_DIGIT_ONLY) && (wParam < '0' || wParam > '9'))
return 0;
else if (my_style & MY_ES_ALPHA_ONLY)
if (!((wParam >= 'A' && wParam <= 'Z') || (wParam >= 'a' && wParam <= 'z')))
/* It is not the desired character, just return. */
return 0;
}
/* Calling old procedure to handle the messages using default handler. */
return (*old_edit_proc) (hwnd, message, wParam, lParam);
}
static LRESULT ControlTestWinProc (HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message) {
case MSG_CREATE:
{
HWND hWnd1, hWnd2, hWnd3;
CreateWindow (CTRL_STATIC, "Digit-only box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
10, 10, 180, 24, hWnd, 0);
hWnd1 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_VISIBLE | WS_BORDER, IDC_CTRL1,
200, 10, 180, 24, hWnd, MY_ES_DIGIT_ONLY);
CreateWindow (CTRL_STATIC, "Alpha-only box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
10, 40, 180, 24, hWnd, 0);
hWnd2 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_BORDER | WS_VISIBLE, IDC_CTRL2,
200, 40, 180, 24, hWnd, MY_ES_ALPHA_ONLY);
CreateWindow (CTRL_STATIC, "Normal edit box:", WS_CHILD | WS_VISIBLE | SS_RIGHT, 0,
10, 70, 180, 24, hWnd, 0);
hWnd3 = CreateWindow (CTRL_EDIT, "", WS_CHILD | WS_BORDER | WS_VISIBLE, IDC_CTRL2,
200, 70, 180, 24, hWnd, MY_ES_ALPHA_ONLY);
CreateWindow ("button", "Close", WS_CHILD | BS_PUSHBUTTON | WS_VISIBLE, IDC_CTRL4,
100, 100, 60, 24, hWnd, 0);
/* Set new window procedure and save the old procedure. */
old_edit_proc = SetWindowCallbackProc (hWnd1, RestrictedEditBox);
SetWindowCallbackProc (hWnd2, RestrictedEditBox);
break;
}
......
}
return DefaultMainWinProc (hWnd, message, wParam, lParam);
}

◆ SetWindowCaption()

BOOL GUIAPI SetWindowCaption ( HWND  hWnd,
const char *  spCaption 
)

Set the caption of a window.

This function sets the caption of the specified window hWnd.

Parameters
hWndThe handle to the window.
spCaptionThe pointer to the new caption of the window.
Returns
TRUE on success, otherwise FALSE.
See also
GetWindowCaption, SetWindowText

◆ SetWindowClassAdditionalData()

DWORD GUIAPI SetWindowClassAdditionalData ( HWND  hWnd,
DWORD  newData 
)

Set the additional data of a control class.

This function sets the additional data of the control class to which the specified control hWnd belongs.

Parameters
hWndThe handle to the control.
newDataThe new additional data of the control class.
Returns
The old additional data of the control class.
Note
This function always does nothing and returns zero for the main window.
See also
SetWindowClassAdditionalData

◆ SetWindowCursor()

HCURSOR GUIAPI SetWindowCursor ( HWND  hWnd,
HCURSOR  hNewCursor 
)

Set the current cursor of a window.

This function sets the current cursor of the specified window hWnd with argument hNewCursor.

Parameters
hWndThe handle to the window.
hNewCursorThe handle to the new cursor.
Returns
The handle to the old cursor.
See also
GetWindowCursor

◆ SetWindowFont()

PLOGFONT GUIAPI SetWindowFont ( HWND  hWnd,
PLOGFONT  pLogFont 
)

Set the default font of a window.

This function sets the default font of the specified window hWnd to be the logical font pLogFont. This function will send an MSG_FONTCHANGING message to the window. If the handler of the message returns non-zero value, this function will return immediately with the unchanged default font. Or, after the new default font set, this function will send an MSG_FONTCHANGED message to the window as a notification.

Parameters
hWndThe handle to the window.
pLogFontThe new default logical font. If it is NULL, this function will set the default font to be the system wchar font.
Returns
The old default logical font of the window, NULL on error.
See also
GetWindowFont, GetSystemFont

◆ SetWindowIcon()

HICON GUIAPI SetWindowIcon ( HWND  hWnd,
HICON  hIcon,
BOOL  bRedraw 
)

Set the current icon of a window.

This function sets the current icon of the specified window hWnd with argument hIcon.

Parameters
hWndThe handle to the window.
hIconThe handle to the new icon.
bRedrawIndicates whether to update the whole window.
Returns
The handle to the old icon.
Note
Note that MiniGUI only provides icon support for main window so far.
See also
GetWindowIcon

◆ SetWindowId()

LINT GUIAPI SetWindowId ( HWND  hWnd,
LINT  lNewId 
)

Set the identifier of a window.

This function sets the identifier of the specified window hWnd to lNewId and returns the old identifier.

Returns
The old identifier of the window. This function returns -1 for an invalid window handle. Therefore, you should avoid to use -1 as a valid identifier of a window.
See also
GetWindowId

◆ SetWindowText()

BOOL GUIAPI SetWindowText ( HWND  hWnd,
const char *  spString 
)

Set the text of a window.

This function copies the string in the buffer pointed to by spString to be the text of the specified window hWnd. The function sets the window text by sending an MSG_SETTEXT message to the window.

Parameters
hWndThe handle to the window.
spStringThe pointer to the buffer.
Returns
TRUE on success, otherwise FALSE.
See also
SetWindowCaption, GetWindowText

◆ ShowWindow()

BOOL GUIAPI ShowWindow ( HWND  hWnd,
int  iCmdShow 
)

Shows or hides a window.

This function shows or hides the window specified by hWnd.

Parameters
hWndThe handle to the window.
iCmdShowThe command to show or hide, can be one of the following values:
  • SW_SHOW
    Shows the window.
  • SW_HIDE
    Hides the window.
  • SW_SHOWNORMAL
    Shows the window, and if the window is a main window sets it to be the top most main window.
Returns
TRUE on sucess, otherwise FALSE.

◆ UpdateInvalidClient()

void GUIAPI UpdateInvalidClient ( HWND  hWnd,
BOOL  bErase 
)

Updates the invalid client areas in a window.

This function updates the client areas specified by hWnd. It will redraw the invalid client area of the window, and if bErase is TRUE, the client area will be erased by using background color.

Parameters
hWndThe handle to the window.
bEraseIndicates whether to erase the client area of the window.
See also
UpdateWindow

◆ UpdateWindow()

void GUIAPI UpdateWindow ( HWND  hWnd,
BOOL  bErase 
)

Updates a window.

This function updates the window specified by hWnd. It will redraw the caption, the frame, and the menu bar of the window. It will invalidate the client area of the window as well, and if bErase is TRUE, the client area will be erased by using background color.

Parameters
hWndThe handle to the window.
bEraseIndicates whether to erase the client area of the window.
See also
InvalidateRect

◆ ValidateRect()

BOOL GUIAPI ValidateRect ( HWND  hWnd,
const RECT rect 
)

Validates the client area within a rectangle by removing the rectangle from the update region of the specified window.

This function validates the client area within a rectangle by removing the rectangle from the update region of the specified window.

Parameters
hWndHandle to the window whose update region is to be modified.
rectPointer to a RECT structure that contains the client coordinates of the rectangle to be removed from the update region. If this parameter is NULL, the entire client area is removed.
Returns
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
Note
The BeginPaint function automatically validates the entire client area. Neither the ValidateRect nor ValidateRegion function should be called if a portion of the update region must be validated before the next MSG_PAINT message is generated. The system continues to generate MSG_PAINT messages until the current update region is validated.
See also
MSG_PAINT, BeginPaint, ValidateRegion, InvalidateRect

◆ ValidateRegion()

BOOL GUIAPI ValidateRegion ( HWND  hWnd,
const CLIPRGN pRgn 
)

Validates the client area within a region by removing the region from the current update region of the specified window.

This function validates the client area within a region by removing the region pRgn from the current update region of the specified window hWnd.

Parameters
hWndHandle to the window whose update region is to be modified.
pRgnA region that defines the area to be removed from the update region. If this parameter is NULL, the entire client area is removed.
Returns
If the function succeeds, the return value is nonzero. If the function fails, the return value is zero.
Note
The specified region must have been created by a region function. The region coordinates are assumed to be client coordinates. The BeginPaint function automatically validates the entire client area. Neither the ValidateRect nor ValidateRegion function should be called if a portion of the update region must be validated before the next MSG_PAINT message is generated.
See also
MSG_PAINT, BeginPaint, ValidateRect, InvalidateRegion

◆ WindowFromPointEx()

HWND GUIAPI WindowFromPointEx ( POINT  pt,
BOOL  bRecursion 
)

Retrieve a handle to the window that contains the specified point.

This function retrieves a handle to the main window that contains the specified point pt.

Parameters
ptSpecifies a POINT structure that defines the point to be checked.
bRecursionTry find the child window of the mMainWindow
Returns
The return value is a handle to the main window that contains the point. If no main window exists at the given point, the return value is HWND_NULL.

◆ WindowToClient()

void GUIAPI WindowToClient ( HWND  hWnd,
int *  x,
int *  y 
)

Converts the window coordinates to client coordinates.

This function converts the window coordinates of the specified point (*x,*y) in the specified window hWnd to the client coordinates.

Parameters
hWndThe handle to the window.
xThe pointer to the x coordinate.
yThe pointer to the y coordinate.
See also
WindowToScreen

◆ WindowToScreen()

void GUIAPI WindowToScreen ( HWND  hWnd,
int *  x,
int *  y 
)

Converts the window coordinates of a point to screen coordinates.

This function converts the window coordinates of the specified point (*x,*y) in the specified window hWnd to the screen coordinates.

Parameters
hWndThe handle to the window.
xThe pointer to the x coordinate.
yThe pointer to the y coordinate.
See also
ScreenToWindow
WS_VISIBLE
#define WS_VISIBLE
Creates a window initially visible.
Definition: window.h:4292
GetWindowAdditionalData
MG_EXPORT DWORD GUIAPI GetWindowAdditionalData(HWND hWnd)
Retrieve the first additional data of a window.
MSG_CREATE
#define MSG_CREATE
Indicates the window has been created, and gives you a chance to initialize your private objects.
Definition: window.h:1352
DWORD
DWORD_PTR DWORD
A unsigned long type definition for pointer precision.
Definition: common.h:604
HWND
GHANDLE HWND
Handle to main window or control.
Definition: common.h:407
WNDPROC
LRESULT(* WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Type of the window callback procedure.
Definition: window.h:4992
BS_PUSHBUTTON
#define BS_PUSHBUTTON
Creates a push button that is a pane that displays either a piece of text or an image and when it is ...
Definition: button.h:103
WPARAM
UINT_PTR WPARAM
A type definition for the first message paramter.
Definition: common.h:706
SetWindowCallbackProc
MG_EXPORT WNDPROC GUIAPI SetWindowCallbackProc(HWND hWnd, WNDPROC newProc)
Set the callback procedure of a window.
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
HWND_DESKTOP
#define HWND_DESKTOP
Desktop window handle.
Definition: window.h:6742
CTRL_STATIC
#define CTRL_STATIC
The class name of static control.
Definition: static.h:84
SS_RIGHT
#define SS_RIGHT
Displays the given text flush-right.
Definition: static.h:180
MSG_CHAR
#define MSG_CHAR
A character translated from MSG_KEYDOWN message.
Definition: window.h:596
WS_CHILD
#define WS_CHILD
Indicates the window is a child.
Definition: window.h:4348
GetNextChild
MG_EXPORT HWND GUIAPI GetNextChild(HWND hWnd, HWND hChild)
Retrieve the next control in a window.
DefaultMainWinProc
#define DefaultMainWinProc
Is the default main window callback procedure.
Definition: window.h:7383
WS_BORDER
#define WS_BORDER
Creates a window with border.
Definition: window.h:4338
CTRL_EDIT
#define CTRL_EDIT
The class name of simple single-line editor box.
Definition: edit.h:87
LPARAM
UINT_PTR LPARAM
A type definition for the second message paramter.
Definition: common.h:712