4 * Copyright 1998 Turchanov Sergey
13 /**********************************************************************/
15 MONITOR_DRIVER *MONITOR_Driver;
17 /**********************************************************************/
19 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
21 MONITOR MONITOR_PrimaryMonitor;
23 /***********************************************************************
27 static MONITOR *MONITOR_GetMonitor(HMONITOR hMonitor)
29 if(hMonitor == xPRIMARY_MONITOR)
31 return &MONITOR_PrimaryMonitor;
40 /***********************************************************************
43 void MONITOR_Initialize(MONITOR *pMonitor)
45 MONITOR_Driver->pInitialize(pMonitor);
48 /***********************************************************************
51 void MONITOR_Finalize(MONITOR *pMonitor)
53 MONITOR_Driver->pFinalize(pMonitor);
56 /***********************************************************************
57 * MONITOR_IsSingleWindow
59 BOOL MONITOR_IsSingleWindow(MONITOR *pMonitor)
61 return MONITOR_Driver->pIsSingleWindow(pMonitor);
64 /***********************************************************************
67 int MONITOR_GetWidth(MONITOR *pMonitor)
69 return MONITOR_Driver->pGetWidth(pMonitor);
72 /***********************************************************************
75 int MONITOR_GetHeight(MONITOR *pMonitor)
77 return MONITOR_Driver->pGetHeight(pMonitor);
80 /***********************************************************************
83 int MONITOR_GetDepth(MONITOR *pMonitor)
85 return MONITOR_Driver->pGetDepth(pMonitor);
88 /***********************************************************************
89 * MONITOR_GetScreenSaveActive
91 BOOL MONITOR_GetScreenSaveActive(MONITOR *pMonitor)
93 return MONITOR_Driver->pGetScreenSaveActive(pMonitor);
96 /***********************************************************************
97 * MONITOR_SetScreenSaveActive
99 void MONITOR_SetScreenSaveActive(MONITOR *pMonitor, BOOL bActivate)
101 MONITOR_Driver->pSetScreenSaveActive(pMonitor, bActivate);
104 /***********************************************************************
105 * MONITOR_GetScreenSaveTimeout
107 int MONITOR_GetScreenSaveTimeout(MONITOR *pMonitor)
109 return MONITOR_Driver->pGetScreenSaveTimeout(pMonitor);
112 /***********************************************************************
113 * MONITOR_SetScreenSaveTimeout
115 void MONITOR_SetScreenSaveTimeout(MONITOR *pMonitor, int nTimeout)
117 MONITOR_Driver->pSetScreenSaveTimeout(pMonitor, nTimeout);
121 /**********************************************************************/
123 HMONITOR WINAPI MonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
125 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
126 ((ptScreenCoords.x >= 0) &&
127 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
128 (ptScreenCoords.y >= 0) &&
129 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
131 return xPRIMARY_MONITOR;
136 HMONITOR WINAPI MonitorFromRect(LPRECT lprcScreenCoords, DWORD dwFlags)
138 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
139 ((lprcScreenCoords->right > 0) &&
140 (lprcScreenCoords->bottom > 0) &&
141 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
142 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
144 return xPRIMARY_MONITOR;
149 HMONITOR WINAPI MonitorFromWindow(HWND hWnd, DWORD dwFlags)
153 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
154 return xPRIMARY_MONITOR;
157 GetWindowPlacement(hWnd, &wp) :
158 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
160 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
166 BOOL WINAPI GetMonitorInfoA(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
170 if ((hMonitor == xPRIMARY_MONITOR) &&
172 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
173 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
175 lpMonitorInfo->rcMonitor.left = 0;
176 lpMonitorInfo->rcMonitor.top = 0;
177 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
178 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
179 lpMonitorInfo->rcWork = rcWork;
180 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
182 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXA))
183 lstrcpyA(((MONITORINFOEXA*)lpMonitorInfo)->szDevice, "DISPLAY");
191 BOOL WINAPI GetMonitorInfoW(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
195 if ((hMonitor == xPRIMARY_MONITOR) &&
197 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
198 SystemParametersInfoW(SPI_GETWORKAREA, 0, &rcWork, 0))
200 lpMonitorInfo->rcMonitor.left = 0;
201 lpMonitorInfo->rcMonitor.top = 0;
202 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
203 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
204 lpMonitorInfo->rcWork = rcWork;
205 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
207 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEXW))
208 lstrcpyW(((MONITORINFOEXW*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
216 BOOL WINAPI EnumDisplayMonitors(
217 HDC hdcOptionalForPainting,
218 LPRECT lprcEnumMonitorsThatIntersect,
219 MONITORENUMPROC lpfnEnumProc,
229 rcLimit.right = GetSystemMetrics(SM_CXSCREEN);
230 rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN);
232 if (hdcOptionalForPainting)
237 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
240 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
243 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
244 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
245 (!lprcEnumMonitorsThatIntersect ||
246 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
257 if ( lprcEnumMonitorsThatIntersect &&
258 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
266 hdcOptionalForPainting,