4 * Copyright 1998 Turchanov Sergey
11 /**********************************************************************/
13 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
15 MONITOR MONITOR_PrimaryMonitor;
17 /***********************************************************************
20 void MONITOR_Initialize(MONITOR *pMonitor)
22 pMonitor->pDriver->pInitialize(pMonitor);
25 /***********************************************************************
28 void MONITOR_Finalize(MONITOR *pMonitor)
30 pMonitor->pDriver->pFinalize(pMonitor);
33 /***********************************************************************
36 int MONITOR_GetWidth(MONITOR *pMonitor)
38 return pMonitor->pDriver->pGetWidth(pMonitor);
41 /***********************************************************************
44 int MONITOR_GetHeight(MONITOR *pMonitor)
46 return pMonitor->pDriver->pGetHeight(pMonitor);
49 /***********************************************************************
52 int MONITOR_GetDepth(MONITOR *pMonitor)
54 return pMonitor->pDriver->pGetDepth(pMonitor);
57 /**********************************************************************/
59 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
61 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
62 ((ptScreenCoords.x >= 0) &&
63 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
64 (ptScreenCoords.y >= 0) &&
65 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
67 return xPRIMARY_MONITOR;
72 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
74 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
75 ((lprcScreenCoords->right > 0) &&
76 (lprcScreenCoords->bottom > 0) &&
77 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
78 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
80 return xPRIMARY_MONITOR;
85 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
89 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
90 return xPRIMARY_MONITOR;
93 GetWindowPlacement(hWnd, &wp) :
94 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
96 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
102 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
106 if ((hMonitor == xPRIMARY_MONITOR) &&
108 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
109 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
111 lpMonitorInfo->rcMonitor.left = 0;
112 lpMonitorInfo->rcMonitor.top = 0;
113 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
114 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
115 lpMonitorInfo->rcWork = rcWork;
116 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
118 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
119 lstrcpyA(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY");
127 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
131 if ((hMonitor == xPRIMARY_MONITOR) &&
133 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
134 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
136 lpMonitorInfo->rcMonitor.left = 0;
137 lpMonitorInfo->rcMonitor.top = 0;
138 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
139 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
140 lpMonitorInfo->rcWork = rcWork;
141 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
143 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
144 lstrcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
152 BOOL WINAPI EnumDisplayMonitors(
153 HDC hdcOptionalForPainting,
154 LPRECT lprcEnumMonitorsThatIntersect,
155 MONITORENUMPROC lpfnEnumProc,
165 rcLimit.right = GetSystemMetrics(SM_CXSCREEN);
166 rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN);
168 if (hdcOptionalForPainting)
173 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
176 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
179 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
180 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
181 (!lprcEnumMonitorsThatIntersect ||
182 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
193 if ( lprcEnumMonitorsThatIntersect &&
194 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
202 hdcOptionalForPainting,