4 * Copyright 1998 Turchanov Sergey
13 /**********************************************************************/
15 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
17 MONITOR MONITOR_PrimaryMonitor
;
19 /**********************************************************************/
21 HMONITOR WINAPI
MonitorFromPoint(POINT ptScreenCoords
, DWORD dwFlags
)
23 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
24 ((ptScreenCoords
.x
>= 0) &&
25 (ptScreenCoords
.x
< GetSystemMetrics(SM_CXSCREEN
)) &&
26 (ptScreenCoords
.y
>= 0) &&
27 (ptScreenCoords
.y
< GetSystemMetrics(SM_CYSCREEN
))))
29 return xPRIMARY_MONITOR
;
34 HMONITOR WINAPI
MonitorFromRect(LPRECT lprcScreenCoords
, DWORD dwFlags
)
36 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
37 ((lprcScreenCoords
->right
> 0) &&
38 (lprcScreenCoords
->bottom
> 0) &&
39 (lprcScreenCoords
->left
< GetSystemMetrics(SM_CXSCREEN
)) &&
40 (lprcScreenCoords
->top
< GetSystemMetrics(SM_CYSCREEN
))))
42 return xPRIMARY_MONITOR
;
47 HMONITOR WINAPI
MonitorFromWindow(HWND hWnd
, DWORD dwFlags
)
51 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
52 return xPRIMARY_MONITOR
;
55 GetWindowPlacement(hWnd
, &wp
) :
56 GetWindowRect(hWnd
, &wp
.rcNormalPosition
)) {
58 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
64 BOOL WINAPI
GetMonitorInfoA(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
68 if ((hMonitor
== xPRIMARY_MONITOR
) &&
70 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
71 SystemParametersInfoA(SPI_GETWORKAREA
, 0, &rcWork
, 0))
73 lpMonitorInfo
->rcMonitor
= MONITOR_PrimaryMonitor
.rect
;
74 lpMonitorInfo
->rcWork
= rcWork
;
75 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
77 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXA
))
78 lstrcpyA(((MONITORINFOEXA
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
86 BOOL WINAPI
GetMonitorInfoW(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
90 if ((hMonitor
== xPRIMARY_MONITOR
) &&
92 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
93 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &rcWork
, 0))
95 lpMonitorInfo
->rcMonitor
= MONITOR_PrimaryMonitor
.rect
;
96 lpMonitorInfo
->rcWork
= rcWork
;
97 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
99 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXW
))
100 lstrcpyW(((MONITORINFOEXW
*)lpMonitorInfo
)->szDevice
, (LPCWSTR
)"D\0I\0S\0P\0L\0A\0Y\0\0");
108 BOOL WINAPI
EnumDisplayMonitors(
109 HDC hdcOptionalForPainting
,
110 LPRECT lprcEnumMonitorsThatIntersect
,
111 MONITORENUMPROC lpfnEnumProc
,
114 RECT rcLimit
= MONITOR_PrimaryMonitor
.rect
;
119 if (hdcOptionalForPainting
)
124 switch (GetClipBox(hdcOptionalForPainting
, &rcClip
))
127 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
130 OffsetRect(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
131 if (IntersectRect(&rcLimit
, &rcLimit
, &rcClip
) &&
132 (!lprcEnumMonitorsThatIntersect
||
133 IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
144 if ( lprcEnumMonitorsThatIntersect
&&
145 !IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
153 hdcOptionalForPainting
,