Below are some Windows API functions and variable types that may be useful. Argument
hWnd is window handle. Use function win
to get window handle. For controls, use child
or id.
| IsWindow(hWnd) |
returns 1 if the handle is valid window handle and the window is not
destroyed. |
| IsZoomed(hWnd) |
returns 1 if window is maximized. |
| IsIconic(hWnd) |
returns 1 if window is minimized. |
| IsWindowVisible(hWnd) |
returns 1 if window is visible. |
| IsWindowEnabled(hWnd) |
returns 1 if window is enabled. |
| EnableWindow(hWnd
fEnable) |
enables (if fEnable is 1) or disables (if fEnable is 0) window. |
| MoveWindow(hWnd
x y nWidth nHeight bRepaint) |
moves and resizes window in one step. bRepaint should be
1. |
| SetWindowPos(hWnd
hWndInsertAfter x y cx cy wFlags) |
moves and/or resizes and/or sets Z
order, and/or more. You'll find required constants defined in function
WinConstants . |
| GetWindowRect(hWnd
RECT*lpRect) |
get window dimensions. |
| GetParent(hWnd) |
returns handle of immediate parent window of child window. |
| GetAncestor(hWnd
gaFlags) |
returns handle of container window. gaFlags: 1 parent (the same as
GetParent), 2 top-level parent, 3 top-level parent or owner. |
| WindowFromPoint(xPoint
yPoint) |
returns handle of window or child window from point. |
Toggle active window's maximized/restored state:
if(IsZoomed(win)) res; else max
Display dimensions of active window:
RECT r; GetWindowRect(win &r)
out "x=%i y=%i width=%i height=%i" r.left r.top r.right-r.left r.bottom-r.top
Get the work area (the portion of the screen not obscured by the system taskbar or by application desktop toolbars):
RECT r; SystemParametersInfo(SPI_GETWORKAREA 0 &r 0)