4 * Copyright 1998 Turchanov Sergey
11 #include "wine/unicode.h"
13 /**********************************************************************/
15 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
17 /***********************************************************************
20 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
22 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
23 ((ptScreenCoords.x >= 0) &&
24 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
25 (ptScreenCoords.y >= 0) &&
26 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
28 return xPRIMARY_MONITOR;
33 /***********************************************************************
36 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
38 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
39 ((lprcScreenCoords->right > 0) &&
40 (lprcScreenCoords->bottom > 0) &&
41 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
42 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
44 return xPRIMARY_MONITOR;
49 /***********************************************************************
52 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
56 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
57 return xPRIMARY_MONITOR;
60 GetWindowPlacement(hWnd, &wp) :
61 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
63 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
69 /***********************************************************************
72 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
76 if ((hMonitor == xPRIMARY_MONITOR) &&
78 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
79 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
81 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
82 GetSystemMetrics(SM_CXSCREEN),
83 GetSystemMetrics(SM_CYSCREEN) );
84 lpMonitorInfo->rcWork = rcWork;
85 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
87 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
88 strcpy(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY");
96 /***********************************************************************
99 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
103 if ((hMonitor == xPRIMARY_MONITOR) &&
105 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
106 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
108 SetRect( &lpMonitorInfo->rcMonitor, 0, 0,
109 GetSystemMetrics(SM_CXSCREEN),
110 GetSystemMetrics(SM_CYSCREEN) );
111 lpMonitorInfo->rcWork = rcWork;
112 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
114 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
115 strcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
123 /***********************************************************************
124 * EnumDisplayMonitors
126 BOOL WINAPI EnumDisplayMonitors(
127 HDC hdcOptionalForPainting,
128 LPRECT lprcEnumMonitorsThatIntersect,
129 MONITORENUMPROC lpfnEnumProc,
133 SetRect( &rcLimit, 0, 0, GetSystemMetrics(SM_CXSCREEN),
134 GetSystemMetrics(SM_CYSCREEN) );
139 if (hdcOptionalForPainting)
144 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
147 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
150 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
151 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
152 (!lprcEnumMonitorsThatIntersect ||
153 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
164 if ( lprcEnumMonitorsThatIntersect &&
165 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
173 hdcOptionalForPainting,