4 * Copyright 1998 Turchanov Sergey
12 /**********************************************************************/
14 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
16 /***********************************************************************
19 HMONITOR WINAPI
MonitorFromPoint(POINT ptScreenCoords
, DWORD dwFlags
)
21 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
22 ((ptScreenCoords
.x
>= 0) &&
23 (ptScreenCoords
.x
< GetSystemMetrics(SM_CXSCREEN
)) &&
24 (ptScreenCoords
.y
>= 0) &&
25 (ptScreenCoords
.y
< GetSystemMetrics(SM_CYSCREEN
))))
27 return xPRIMARY_MONITOR
;
32 /***********************************************************************
35 HMONITOR WINAPI
MonitorFromRect(LPRECT lprcScreenCoords
, DWORD dwFlags
)
37 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
38 ((lprcScreenCoords
->right
> 0) &&
39 (lprcScreenCoords
->bottom
> 0) &&
40 (lprcScreenCoords
->left
< GetSystemMetrics(SM_CXSCREEN
)) &&
41 (lprcScreenCoords
->top
< GetSystemMetrics(SM_CYSCREEN
))))
43 return xPRIMARY_MONITOR
;
48 /***********************************************************************
51 HMONITOR WINAPI
MonitorFromWindow(HWND hWnd
, DWORD dwFlags
)
55 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
56 return xPRIMARY_MONITOR
;
59 GetWindowPlacement(hWnd
, &wp
) :
60 GetWindowRect(hWnd
, &wp
.rcNormalPosition
)) {
62 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
68 /***********************************************************************
71 BOOL WINAPI
GetMonitorInfoA(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
75 if ((hMonitor
== xPRIMARY_MONITOR
) &&
77 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
78 SystemParametersInfoA(SPI_GETWORKAREA
, 0, &rcWork
, 0))
80 SetRect( &lpMonitorInfo
->rcMonitor
, 0, 0,
81 GetSystemMetrics(SM_CXSCREEN
),
82 GetSystemMetrics(SM_CYSCREEN
) );
83 lpMonitorInfo
->rcWork
= rcWork
;
84 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
86 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXA
))
87 lstrcpyA(((MONITORINFOEXA
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
95 /***********************************************************************
98 BOOL WINAPI
GetMonitorInfoW(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
102 if ((hMonitor
== xPRIMARY_MONITOR
) &&
104 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
105 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &rcWork
, 0))
107 SetRect( &lpMonitorInfo
->rcMonitor
, 0, 0,
108 GetSystemMetrics(SM_CXSCREEN
),
109 GetSystemMetrics(SM_CYSCREEN
) );
110 lpMonitorInfo
->rcWork
= rcWork
;
111 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
113 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXW
))
114 lstrcpyW(((MONITORINFOEXW
*)lpMonitorInfo
)->szDevice
, (LPCWSTR
)"D\0I\0S\0P\0L\0A\0Y\0\0");
122 /***********************************************************************
123 * EnumDisplayMonitors
125 BOOL WINAPI
EnumDisplayMonitors(
126 HDC hdcOptionalForPainting
,
127 LPRECT lprcEnumMonitorsThatIntersect
,
128 MONITORENUMPROC lpfnEnumProc
,
132 SetRect( &rcLimit
, 0, 0, GetSystemMetrics(SM_CXSCREEN
),
133 GetSystemMetrics(SM_CYSCREEN
) );
138 if (hdcOptionalForPainting
)
143 switch (GetClipBox(hdcOptionalForPainting
, &rcClip
))
146 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
149 OffsetRect(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
150 if (IntersectRect(&rcLimit
, &rcLimit
, &rcClip
) &&
151 (!lprcEnumMonitorsThatIntersect
||
152 IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
163 if ( lprcEnumMonitorsThatIntersect
&&
164 !IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
172 hdcOptionalForPainting
,