4 * Copyright 1998 Turchanov Sergey
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
26 #include "wine/unicode.h"
28 /**********************************************************************/
30 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
32 /***********************************************************************
33 * MonitorFromPoint (USER32.@)
35 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
37 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
38 ((ptScreenCoords.x >= 0) &&
39 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
40 (ptScreenCoords.y >= 0) &&
41 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
43 return xPRIMARY_MONITOR;
48 /***********************************************************************
49 * MonitorFromRect (USER32.@)
51 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
53 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
54 ((lprcScreenCoords->right > 0) &&
55 (lprcScreenCoords->bottom > 0) &&
56 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
57 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
59 return xPRIMARY_MONITOR;
64 /***********************************************************************
65 * MonitorFromWindow (USER32.@)
67 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
71 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
72 return xPRIMARY_MONITOR;
75 GetWindowPlacement(hWnd, &wp) :
76 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
78 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
84 /***********************************************************************
85 * GetMonitorInfoA (USER32.@)
87 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
91 if ((hMonitor == xPRIMARY_MONITOR) &&
93 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
94 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
96 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
97 GetSystemMetrics(SM_CXSCREEN),
98 GetSystemMetrics(SM_CYSCREEN) );
99 lpMonitorInfo->rcWork = rcWork;
100 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
102 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
103 strcpy(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY");
111 /***********************************************************************
112 * GetMonitorInfoW (USER32.@)
114 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
118 if ((hMonitor == xPRIMARY_MONITOR) &&
120 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
121 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
123 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
124 GetSystemMetrics(SM_CXSCREEN),
125 GetSystemMetrics(SM_CYSCREEN) );
126 lpMonitorInfo->rcWork = rcWork;
127 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
129 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
130 strcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
138 /***********************************************************************
139 * EnumDisplayMonitors (USER32.@)
141 BOOL WINAPI EnumDisplayMonitors(
142 HDC hdcOptionalForPainting,
143 LPRECT lprcEnumMonitorsThatIntersect,
144 MONITORENUMPROC lpfnEnumProc,
148 SetRect( &rcLimit, 0, 0, GetSystemMetrics(SM_CXSCREEN),
149 GetSystemMetrics(SM_CYSCREEN) );
154 if (hdcOptionalForPainting)
159 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
162 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
165 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
166 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
167 (!lprcEnumMonitorsThatIntersect ||
168 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
179 if ( lprcEnumMonitorsThatIntersect &&
180 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
188 hdcOptionalForPainting,