Requires: Gfawinx.lg32
Retrieves the work area of the monitor containing the largest area of a given window.
GetWorkArea [hWnd] , left, top, width, height
hWnd | : Window handle |
height, left, top, width | : integer variables |
GetWorkArea retrieves the coordinates and size of the work area of the display monitor that has the largest area of intersection with the bounding rectangle of a specified window hWnd and the values are returned in the variables passed to the procedure. If hWnd is omitted GetWorkArea returns the monitor-coordinates for Me. If hWnd is 0 (Null) GetWorkArea returns the coordinates of the entire desktop.
An application should use GetWorkArea rather than the Screen properties WorkLeft, WorkTop, WorkWidth, WorkHeight; these properties return values for the primary monitor only, not necessarily the monitor on which the application is running.
$Library "gfawinx"
Global Int WorkLeft, WorkTop, WorkWidth, WorkHeight
OpenW 1
Print "Move/size window to a different monitor"
Do
Sleep
Until Me Is Nothing
Sub Win_1_Paint
Text 0, 0, WorkLeft & ", " & WorkTop & ", " & WorkWidth & ", " & WorkHeight
EndSub
Sub Win_1_Moved
GetWorkArea Me.hWnd, WorkLeft, WorkTop, WorkWidth, WorkHeight
Me.InvalidateAll
EndSub
Sub Win_1_ReSize
GetWorkArea Me.hWnd, WorkLeft, WorkTop, WorkWidth, WorkHeight
EndSub
If the window intersects with one or more display monitor rectangles, the window scales to the display settings of the display monitor that has the largest area of intersection with the window. By using GetWorkArea the application can continue to work with the actual coordinates and size of that display monitor.
{Created by Sjouke Hamstra; Last updated: 24/02/2022 by James Gaite}