4 * Copyright 1998 Turchanov Sergey
13 /**********************************************************************/
15 MONITOR_DRIVER
*MONITOR_Driver
;
17 /**********************************************************************/
19 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
21 MONITOR MONITOR_PrimaryMonitor
;
23 /***********************************************************************
26 static MONITOR
*MONITOR_GetMonitor(HMONITOR hMonitor
)
28 if(hMonitor
== xPRIMARY_MONITOR
)
30 return &MONITOR_PrimaryMonitor
;
38 /***********************************************************************
41 void MONITOR_Initialize(MONITOR
*pMonitor
)
43 MONITOR_Driver
->pInitialize(pMonitor
);
46 /***********************************************************************
49 void MONITOR_Finalize(MONITOR
*pMonitor
)
51 MONITOR_Driver
->pFinalize(pMonitor
);
54 /***********************************************************************
55 * MONITOR_IsSingleWindow
57 BOOL
MONITOR_IsSingleWindow(MONITOR
*pMonitor
)
59 return MONITOR_Driver
->pIsSingleWindow(pMonitor
);
62 /***********************************************************************
65 int MONITOR_GetWidth(MONITOR
*pMonitor
)
67 return MONITOR_Driver
->pGetWidth(pMonitor
);
70 /***********************************************************************
73 int MONITOR_GetHeight(MONITOR
*pMonitor
)
75 return MONITOR_Driver
->pGetHeight(pMonitor
);
78 /***********************************************************************
81 int MONITOR_GetDepth(MONITOR
*pMonitor
)
83 return MONITOR_Driver
->pGetDepth(pMonitor
);
86 /***********************************************************************
87 * MONITOR_GetScreenSaveActive
89 BOOL
MONITOR_GetScreenSaveActive(MONITOR
*pMonitor
)
91 return MONITOR_Driver
->pGetScreenSaveActive(pMonitor
);
94 /***********************************************************************
95 * MONITOR_SetScreenSaveActive
97 void MONITOR_SetScreenSaveActive(MONITOR
*pMonitor
, BOOL bActivate
)
99 MONITOR_Driver
->pSetScreenSaveActive(pMonitor
, bActivate
);
102 /***********************************************************************
103 * MONITOR_GetScreenSaveTimeout
105 int MONITOR_GetScreenSaveTimeout(MONITOR
*pMonitor
)
107 return MONITOR_Driver
->pGetScreenSaveTimeout(pMonitor
);
110 /***********************************************************************
111 * MONITOR_SetScreenSaveTimeout
113 void MONITOR_SetScreenSaveTimeout(MONITOR
*pMonitor
, int nTimeout
)
115 MONITOR_Driver
->pSetScreenSaveTimeout(pMonitor
, nTimeout
);
119 /**********************************************************************/
121 HMONITOR WINAPI
MonitorFromPoint(POINT ptScreenCoords
, DWORD dwFlags
)
123 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
124 ((ptScreenCoords
.x
>= 0) &&
125 (ptScreenCoords
.x
< GetSystemMetrics(SM_CXSCREEN
)) &&
126 (ptScreenCoords
.y
>= 0) &&
127 (ptScreenCoords
.y
< GetSystemMetrics(SM_CYSCREEN
))))
129 return xPRIMARY_MONITOR
;
134 HMONITOR WINAPI
MonitorFromRect(LPRECT lprcScreenCoords
, DWORD dwFlags
)
136 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
137 ((lprcScreenCoords
->right
> 0) &&
138 (lprcScreenCoords
->bottom
> 0) &&
139 (lprcScreenCoords
->left
< GetSystemMetrics(SM_CXSCREEN
)) &&
140 (lprcScreenCoords
->top
< GetSystemMetrics(SM_CYSCREEN
))))
142 return xPRIMARY_MONITOR
;
147 HMONITOR WINAPI
MonitorFromWindow(HWND hWnd
, DWORD dwFlags
)
151 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
152 return xPRIMARY_MONITOR
;
155 GetWindowPlacement(hWnd
, &wp
) :
156 GetWindowRect(hWnd
, &wp
.rcNormalPosition
)) {
158 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
164 BOOL WINAPI
GetMonitorInfoA(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
168 if ((hMonitor
== xPRIMARY_MONITOR
) &&
170 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
171 SystemParametersInfoA(SPI_GETWORKAREA
, 0, &rcWork
, 0))
173 lpMonitorInfo
->rcMonitor
.left
= 0;
174 lpMonitorInfo
->rcMonitor
.top
= 0;
175 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics(SM_CXSCREEN
);
176 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics(SM_CYSCREEN
);
177 lpMonitorInfo
->rcWork
= rcWork
;
178 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
180 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXA
))
181 lstrcpyA(((MONITORINFOEXA
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
189 BOOL WINAPI
GetMonitorInfoW(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
193 if ((hMonitor
== xPRIMARY_MONITOR
) &&
195 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
196 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &rcWork
, 0))
198 lpMonitorInfo
->rcMonitor
.left
= 0;
199 lpMonitorInfo
->rcMonitor
.top
= 0;
200 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics(SM_CXSCREEN
);
201 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics(SM_CYSCREEN
);
202 lpMonitorInfo
->rcWork
= rcWork
;
203 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
205 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXW
))
206 lstrcpyW(((MONITORINFOEXW
*)lpMonitorInfo
)->szDevice
, (LPCWSTR
)"D\0I\0S\0P\0L\0A\0Y\0\0");
214 BOOL WINAPI
EnumDisplayMonitors(
215 HDC hdcOptionalForPainting
,
216 LPRECT lprcEnumMonitorsThatIntersect
,
217 MONITORENUMPROC lpfnEnumProc
,
227 rcLimit
.right
= GetSystemMetrics(SM_CXSCREEN
);
228 rcLimit
.bottom
= GetSystemMetrics(SM_CYSCREEN
);
230 if (hdcOptionalForPainting
)
235 switch (GetClipBox(hdcOptionalForPainting
, &rcClip
))
238 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
241 OffsetRect(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
242 if (IntersectRect(&rcLimit
, &rcLimit
, &rcClip
) &&
243 (!lprcEnumMonitorsThatIntersect
||
244 IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
255 if ( lprcEnumMonitorsThatIntersect
&&
256 !IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
264 hdcOptionalForPainting
,