4 * Copyright 1998 Turchanov Sergey
9 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
11 HMONITOR WINAPI
MonitorFromPoint(POINT32 ptScreenCoords
, DWORD dwFlags
)
13 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
14 ((ptScreenCoords
.x
>= 0) &&
15 (ptScreenCoords
.x
< GetSystemMetrics32(SM_CXSCREEN
)) &&
16 (ptScreenCoords
.y
>= 0) &&
17 (ptScreenCoords
.y
< GetSystemMetrics32(SM_CYSCREEN
))))
19 return xPRIMARY_MONITOR
;
24 HMONITOR WINAPI
MonitorFromRect(LPRECT32 lprcScreenCoords
, DWORD dwFlags
)
26 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
27 ((lprcScreenCoords
->right
> 0) &&
28 (lprcScreenCoords
->bottom
> 0) &&
29 (lprcScreenCoords
->left
< GetSystemMetrics32(SM_CXSCREEN
)) &&
30 (lprcScreenCoords
->top
< GetSystemMetrics32(SM_CYSCREEN
))))
32 return xPRIMARY_MONITOR
;
37 HMONITOR WINAPI
MonitorFromWindow(HWND32 hWnd
, DWORD dwFlags
)
41 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
42 return xPRIMARY_MONITOR
;
44 if (IsIconic32(hWnd
) ?
45 GetWindowPlacement32(hWnd
, &wp
) :
46 GetWindowRect32(hWnd
, &wp
.rcNormalPosition
)) {
48 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
54 BOOL32 WINAPI
GetMonitorInfo32A(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
58 if ((hMonitor
== xPRIMARY_MONITOR
) &&
60 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
61 SystemParametersInfo32A(SPI_GETWORKAREA
, 0, &rcWork
, 0))
63 lpMonitorInfo
->rcMonitor
.left
= 0;
64 lpMonitorInfo
->rcMonitor
.top
= 0;
65 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics32(SM_CXSCREEN
);
66 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
67 lpMonitorInfo
->rcWork
= rcWork
;
68 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
70 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEX32A
))
71 lstrcpy32A(((MONITORINFOEX32A
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
79 BOOL32 WINAPI
GetMonitorInfo32W(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
83 if ((hMonitor
== xPRIMARY_MONITOR
) &&
85 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
86 SystemParametersInfo32W(SPI_GETWORKAREA
, 0, &rcWork
, 0))
88 lpMonitorInfo
->rcMonitor
.left
= 0;
89 lpMonitorInfo
->rcMonitor
.top
= 0;
90 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics32(SM_CXSCREEN
);
91 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
92 lpMonitorInfo
->rcWork
= rcWork
;
93 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
95 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEX32W
))
96 lstrcpy32W(((MONITORINFOEX32W
*)lpMonitorInfo
)->szDevice
, "D\0I\0S\0P\0L\0A\0Y\0\0");
104 BOOL32 WINAPI
EnumDisplayMonitors(
105 HDC32 hdcOptionalForPainting
,
106 LPRECT32 lprcEnumMonitorsThatIntersect
,
107 MONITORENUMPROC lpfnEnumProc
,
117 rcLimit
.right
= GetSystemMetrics32(SM_CXSCREEN
);
118 rcLimit
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
120 if (hdcOptionalForPainting
)
125 switch (GetClipBox32(hdcOptionalForPainting
, &rcClip
))
128 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
131 OffsetRect32(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
132 if (IntersectRect32(&rcLimit
, &rcLimit
, &rcClip
) &&
133 (!lprcEnumMonitorsThatIntersect
||
134 IntersectRect32(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
145 if ( lprcEnumMonitorsThatIntersect
&&
146 !IntersectRect32(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
154 hdcOptionalForPainting
,