Extensions: window

Category: window. To get help, type or click function name in editor and press F1.

 

GetWinXY return window dimensions
GetWinStyle return window style or extended style
GetWinId return child window id
WinC find window that has certain child window
ArrangeWindows arrange windows
   
and more  

 

 

Windows API window functions

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.

 

type POINT x y used to store point coordinates
type RECT left top right bottom used to store rectangle coordinates

 

You can use functions GetSystemMetrics and SystemParametersInfo to get various system parameters. These and other Windows API functions are documented in MSDN library.

 

Examples

 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)