4 * Copyright 1998 Turchanov Sergey
13 /**********************************************************************/
15 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
17 MONITOR MONITOR_PrimaryMonitor;
19 /***********************************************************************
22 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
24 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
25 ((ptScreenCoords.x >= 0) &&
26 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
27 (ptScreenCoords.y >= 0) &&
28 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
30 return xPRIMARY_MONITOR;
35 /***********************************************************************
38 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
40 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
41 ((lprcScreenCoords->right > 0) &&
42 (lprcScreenCoords->bottom > 0) &&
43 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
44 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
46 return xPRIMARY_MONITOR;
51 /***********************************************************************
54 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
58 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
59 return xPRIMARY_MONITOR;
62 GetWindowPlacement(hWnd, &wp) :
63 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
65 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
71 /***********************************************************************
74 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
78 if ((hMonitor == xPRIMARY_MONITOR) &&
80 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
81 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
83 lpMonitorInfo->rcMonitor = MONITOR_PrimaryMonitor.rect;
84 lpMonitorInfo->rcWork = rcWork;
85 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
87 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
88 lstrcpyA(((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 lpMonitorInfo->rcMonitor = MONITOR_PrimaryMonitor.rect;
109 lpMonitorInfo->rcWork = rcWork;
110 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
112 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
113 lstrcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
121 /***********************************************************************
122 * EnumDisplayMonitors
124 BOOL WINAPI EnumDisplayMonitors(
125 HDC hdcOptionalForPainting,
126 LPRECT lprcEnumMonitorsThatIntersect,
127 MONITORENUMPROC lpfnEnumProc,
130 RECT rcLimit = MONITOR_PrimaryMonitor.rect;
135 if (hdcOptionalForPainting)
140 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
143 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
146 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
147 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
148 (!lprcEnumMonitorsThatIntersect ||
149 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
160 if ( lprcEnumMonitorsThatIntersect &&
161 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
169 hdcOptionalForPainting,