Build virtual screen rectangle
An old thread but helpful, thanks.
Something to consider is that the primary monitor may not always be the top-left-most monitor. Using a couple more API calls you can build a 'virtual screen' -- image the smallest rectangle that you can draw to fit all of the monitors in.
The top-left of the primary monitor is the reference point (0,0), so if you have another monitor to the left or above the primary monitor, vscreen_left and vscreen_top will be negative.
You can use these values to compare against window X and Y attributes for example.
Code:
run GetSystemMetrics (76 /*SM_XVIRTUALSCREEN*/, output vscreen_left).
run GetSystemMetrics (77 /*SM_YVIRTUALSCREEN*/, output vscreen_top).
run GetSystemMetrics (78 /*SM_CXVIRTUALSCREEN*/, output vscreen_right).
vscreen_right = vscreen_left + vscreen_right.
run GetSystemMetrics (79 /*SM_CYVIRTUALSCREEN*/, output vg_vscreen_bottom).
vscreen_bottom = vscreen_top + vscreen_bottom.
GetSystemMetrics ref:
http://msdn.microsoft.com/en-us/library/windows/desktop/ms724385(v=vs.85).aspx
This doesn't necessarily provide an exact indication of the actual viewable area, because multiple monitors may be different sizes or placed offset to each other, but it is close enough for most applications. If anyone has written code to enumerate each monitor's dimensions I'd love to see it