4 * Copyright 1998 Turchanov Sergey
11 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
13 HMONITOR WINAPI
MonitorFromPoint(POINT32 ptScreenCoords
, DWORD dwFlags
)
15 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
16 ((ptScreenCoords
.x
>= 0) &&
17 (ptScreenCoords
.x
< GetSystemMetrics32(SM_CXSCREEN
)) &&
18 (ptScreenCoords
.y
>= 0) &&
19 (ptScreenCoords
.y
< GetSystemMetrics32(SM_CYSCREEN
))))
21 return xPRIMARY_MONITOR
;
26 HMONITOR WINAPI
MonitorFromRect(LPRECT32 lprcScreenCoords
, DWORD dwFlags
)
28 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
29 ((lprcScreenCoords
->right
> 0) &&
30 (lprcScreenCoords
->bottom
> 0) &&
31 (lprcScreenCoords
->left
< GetSystemMetrics32(SM_CXSCREEN
)) &&
32 (lprcScreenCoords
->top
< GetSystemMetrics32(SM_CYSCREEN
))))
34 return xPRIMARY_MONITOR
;
39 HMONITOR WINAPI
MonitorFromWindow(HWND32 hWnd
, DWORD dwFlags
)
43 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
44 return xPRIMARY_MONITOR
;
46 if (IsIconic32(hWnd
) ?
47 GetWindowPlacement32(hWnd
, &wp
) :
48 GetWindowRect32(hWnd
, &wp
.rcNormalPosition
)) {
50 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
56 BOOL32 WINAPI
GetMonitorInfo32A(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
60 if ((hMonitor
== xPRIMARY_MONITOR
) &&
62 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
63 SystemParametersInfo32A(SPI_GETWORKAREA
, 0, &rcWork
, 0))
65 lpMonitorInfo
->rcMonitor
.left
= 0;
66 lpMonitorInfo
->rcMonitor
.top
= 0;
67 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics32(SM_CXSCREEN
);
68 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
69 lpMonitorInfo
->rcWork
= rcWork
;
70 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
72 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEX32A
))
73 lstrcpy32A(((MONITORINFOEX32A
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
81 BOOL32 WINAPI
GetMonitorInfo32W(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
85 if ((hMonitor
== xPRIMARY_MONITOR
) &&
87 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
88 SystemParametersInfo32W(SPI_GETWORKAREA
, 0, &rcWork
, 0))
90 lpMonitorInfo
->rcMonitor
.left
= 0;
91 lpMonitorInfo
->rcMonitor
.top
= 0;
92 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics32(SM_CXSCREEN
);
93 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
94 lpMonitorInfo
->rcWork
= rcWork
;
95 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
97 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEX32W
))
98 lstrcpy32W(((MONITORINFOEX32W
*)lpMonitorInfo
)->szDevice
, "D\0I\0S\0P\0L\0A\0Y\0\0");
106 BOOL32 WINAPI
EnumDisplayMonitors(
107 HDC32 hdcOptionalForPainting
,
108 LPRECT32 lprcEnumMonitorsThatIntersect
,
109 MONITORENUMPROC lpfnEnumProc
,
119 rcLimit
.right
= GetSystemMetrics32(SM_CXSCREEN
);
120 rcLimit
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
122 if (hdcOptionalForPainting
)
127 switch (GetClipBox32(hdcOptionalForPainting
, &rcClip
))
130 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
133 OffsetRect32(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
134 if (IntersectRect32(&rcLimit
, &rcLimit
, &rcClip
) &&
135 (!lprcEnumMonitorsThatIntersect
||
136 IntersectRect32(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
147 if ( lprcEnumMonitorsThatIntersect
&&
148 !IntersectRect32(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
156 hdcOptionalForPainting
,