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(POINT32 ptScreenCoords, DWORD dwFlags)
61 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
62 ((ptScreenCoords.x >= 0) &&
63 (ptScreenCoords.x < GetSystemMetrics32(SM_CXSCREEN)) &&
64 (ptScreenCoords.y >= 0) &&
65 (ptScreenCoords.y < GetSystemMetrics32(SM_CYSCREEN))))
67 return xPRIMARY_MONITOR;
72 HMONITOR WINAPI MonitorFromRect(LPRECT32 lprcScreenCoords, DWORD dwFlags)
74 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
75 ((lprcScreenCoords->right > 0) &&
76 (lprcScreenCoords->bottom > 0) &&
77 (lprcScreenCoords->left < GetSystemMetrics32(SM_CXSCREEN)) &&
78 (lprcScreenCoords->top < GetSystemMetrics32(SM_CYSCREEN))))
80 return xPRIMARY_MONITOR;
85 HMONITOR WINAPI MonitorFromWindow(HWND32 hWnd, DWORD dwFlags)
89 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
90 return xPRIMARY_MONITOR;
92 if (IsIconic32(hWnd) ?
93 GetWindowPlacement32(hWnd, &wp) :
94 GetWindowRect32(hWnd, &wp.rcNormalPosition)) {
96 return MonitorFromRect(&wp.rcNormalPosition, dwFlags);
102 BOOL32 WINAPI GetMonitorInfo32A(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
106 if ((hMonitor == xPRIMARY_MONITOR) &&
108 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
109 SystemParametersInfo32A(SPI_GETWORKAREA, 0, &rcWork, 0))
111 lpMonitorInfo->rcMonitor.left = 0;
112 lpMonitorInfo->rcMonitor.top = 0;
113 lpMonitorInfo->rcMonitor.right = GetSystemMetrics32(SM_CXSCREEN);
114 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics32(SM_CYSCREEN);
115 lpMonitorInfo->rcWork = rcWork;
116 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
118 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX32A))
119 lstrcpy32A(((MONITORINFOEX32A*)lpMonitorInfo)->szDevice, "DISPLAY");
127 BOOL32 WINAPI GetMonitorInfo32W(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
131 if ((hMonitor == xPRIMARY_MONITOR) &&
133 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
134 SystemParametersInfo32W(SPI_GETWORKAREA, 0, &rcWork, 0))
136 lpMonitorInfo->rcMonitor.left = 0;
137 lpMonitorInfo->rcMonitor.top = 0;
138 lpMonitorInfo->rcMonitor.right = GetSystemMetrics32(SM_CXSCREEN);
139 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics32(SM_CYSCREEN);
140 lpMonitorInfo->rcWork = rcWork;
141 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
143 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX32W))
144 lstrcpy32W(((MONITORINFOEX32W*)lpMonitorInfo)->szDevice, (LPCWSTR)"D\0I\0S\0P\0L\0A\0Y\0\0");
152 BOOL32 WINAPI EnumDisplayMonitors(
153 HDC32 hdcOptionalForPainting,
154 LPRECT32 lprcEnumMonitorsThatIntersect,
155 MONITORENUMPROC lpfnEnumProc,
165 rcLimit.right = GetSystemMetrics32(SM_CXSCREEN);
166 rcLimit.bottom = GetSystemMetrics32(SM_CYSCREEN);
168 if (hdcOptionalForPainting)
173 switch (GetClipBox32(hdcOptionalForPainting, &rcClip))
176 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
179 OffsetRect32(&rcLimit, -ptOrg.x, -ptOrg.y);
180 if (IntersectRect32(&rcLimit, &rcLimit, &rcClip) &&
181 (!lprcEnumMonitorsThatIntersect ||
182 IntersectRect32(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
193 if ( lprcEnumMonitorsThatIntersect &&
194 !IntersectRect32(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
202 hdcOptionalForPainting,