4 * Copyright 1998 Turchanov Sergey
12 #include "wine/unicode.h"
14 /**********************************************************************/
16 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
18 /***********************************************************************
19 * MonitorFromPoint (USER32.@)
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 /***********************************************************************
35 * MonitorFromRect (USER32.@)
37 HMONITOR WINAPI
MonitorFromRect(LPRECT lprcScreenCoords
, DWORD dwFlags
)
39 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
40 ((lprcScreenCoords
->right
> 0) &&
41 (lprcScreenCoords
->bottom
> 0) &&
42 (lprcScreenCoords
->left
< GetSystemMetrics(SM_CXSCREEN
)) &&
43 (lprcScreenCoords
->top
< GetSystemMetrics(SM_CYSCREEN
))))
45 return xPRIMARY_MONITOR
;
50 /***********************************************************************
51 * MonitorFromWindow (USER32.@)
53 HMONITOR WINAPI
MonitorFromWindow(HWND hWnd
, DWORD dwFlags
)
57 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
58 return xPRIMARY_MONITOR
;
61 GetWindowPlacement(hWnd
, &wp
) :
62 GetWindowRect(hWnd
, &wp
.rcNormalPosition
)) {
64 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
70 /***********************************************************************
71 * GetMonitorInfoA (USER32.@)
73 BOOL WINAPI
GetMonitorInfoA(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
77 if ((hMonitor
== xPRIMARY_MONITOR
) &&
79 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
80 SystemParametersInfoA(SPI_GETWORKAREA
, 0, &rcWork
, 0))
82 SetRect( &lpMonitorInfo
->rcMonitor
, 0, 0,
83 GetSystemMetrics(SM_CXSCREEN
),
84 GetSystemMetrics(SM_CYSCREEN
) );
85 lpMonitorInfo
->rcWork
= rcWork
;
86 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
88 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXA
))
89 strcpy(((MONITORINFOEXA
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
97 /***********************************************************************
98 * GetMonitorInfoW (USER32.@)
100 BOOL WINAPI
GetMonitorInfoW(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
104 if ((hMonitor
== xPRIMARY_MONITOR
) &&
106 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
107 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &rcWork
, 0))
109 SetRect( &lpMonitorInfo
->rcMonitor
, 0, 0,
110 GetSystemMetrics(SM_CXSCREEN
),
111 GetSystemMetrics(SM_CYSCREEN
) );
112 lpMonitorInfo
->rcWork
= rcWork
;
113 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
115 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXW
))
116 strcpyW(((MONITORINFOEXW
*)lpMonitorInfo
)->szDevice
, (LPCWSTR
)"D\0I\0S\0P\0L\0A\0Y\0\0");
124 /***********************************************************************
125 * EnumDisplayMonitors (USER32.@)
127 BOOL WINAPI
EnumDisplayMonitors(
128 HDC hdcOptionalForPainting
,
129 LPRECT lprcEnumMonitorsThatIntersect
,
130 MONITORENUMPROC lpfnEnumProc
,
134 SetRect( &rcLimit
, 0, 0, GetSystemMetrics(SM_CXSCREEN
),
135 GetSystemMetrics(SM_CYSCREEN
) );
140 if (hdcOptionalForPainting
)
145 switch (GetClipBox(hdcOptionalForPainting
, &rcClip
))
148 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
151 OffsetRect(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
152 if (IntersectRect(&rcLimit
, &rcLimit
, &rcClip
) &&
153 (!lprcEnumMonitorsThatIntersect
||
154 IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
165 if ( lprcEnumMonitorsThatIntersect
&&
166 !IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
174 hdcOptionalForPainting
,