4 * Copyright 1998 Turchanov Sergey
11 /**********************************************************************/
13 MONITOR_DRIVER
*MONITOR_Driver
;
15 /**********************************************************************/
17 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
19 MONITOR MONITOR_PrimaryMonitor
;
21 /***********************************************************************
24 static MONITOR
*MONITOR_GetMonitor(HMONITOR hMonitor
)
26 if(hMonitor
== xPRIMARY_MONITOR
)
28 return &MONITOR_PrimaryMonitor
;
36 /***********************************************************************
39 void MONITOR_Initialize(MONITOR
*pMonitor
)
41 MONITOR_Driver
->pInitialize(pMonitor
);
44 /***********************************************************************
47 void MONITOR_Finalize(MONITOR
*pMonitor
)
49 MONITOR_Driver
->pFinalize(pMonitor
);
52 /***********************************************************************
53 * MONITOR_IsSingleWindow
55 BOOL
MONITOR_IsSingleWindow(MONITOR
*pMonitor
)
57 return MONITOR_Driver
->pIsSingleWindow(pMonitor
);
60 /***********************************************************************
63 int MONITOR_GetWidth(MONITOR
*pMonitor
)
65 return MONITOR_Driver
->pGetWidth(pMonitor
);
68 /***********************************************************************
71 int MONITOR_GetHeight(MONITOR
*pMonitor
)
73 return MONITOR_Driver
->pGetHeight(pMonitor
);
76 /***********************************************************************
79 int MONITOR_GetDepth(MONITOR
*pMonitor
)
81 return MONITOR_Driver
->pGetDepth(pMonitor
);
84 /***********************************************************************
85 * MONITOR_GetScreenSaveActive
87 BOOL
MONITOR_GetScreenSaveActive(MONITOR
*pMonitor
)
89 return MONITOR_Driver
->pGetScreenSaveActive(pMonitor
);
92 /***********************************************************************
93 * MONITOR_SetScreenSaveActive
95 void MONITOR_SetScreenSaveActive(MONITOR
*pMonitor
, BOOL bActivate
)
97 MONITOR_Driver
->pSetScreenSaveActive(pMonitor
, bActivate
);
100 /***********************************************************************
101 * MONITOR_GetScreenSaveTimeout
103 int MONITOR_GetScreenSaveTimeout(MONITOR
*pMonitor
)
105 return MONITOR_Driver
->pGetScreenSaveTimeout(pMonitor
);
108 /***********************************************************************
109 * MONITOR_SetScreenSaveTimeout
111 void MONITOR_SetScreenSaveTimeout(MONITOR
*pMonitor
, int nTimeout
)
113 MONITOR_Driver
->pSetScreenSaveTimeout(pMonitor
, nTimeout
);
117 /**********************************************************************/
119 HMONITOR WINAPI
MonitorFromPoint(POINT ptScreenCoords
, DWORD dwFlags
)
121 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
122 ((ptScreenCoords
.x
>= 0) &&
123 (ptScreenCoords
.x
< GetSystemMetrics(SM_CXSCREEN
)) &&
124 (ptScreenCoords
.y
>= 0) &&
125 (ptScreenCoords
.y
< GetSystemMetrics(SM_CYSCREEN
))))
127 return xPRIMARY_MONITOR
;
132 HMONITOR WINAPI
MonitorFromRect(LPRECT lprcScreenCoords
, DWORD dwFlags
)
134 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
135 ((lprcScreenCoords
->right
> 0) &&
136 (lprcScreenCoords
->bottom
> 0) &&
137 (lprcScreenCoords
->left
< GetSystemMetrics(SM_CXSCREEN
)) &&
138 (lprcScreenCoords
->top
< GetSystemMetrics(SM_CYSCREEN
))))
140 return xPRIMARY_MONITOR
;
145 HMONITOR WINAPI
MonitorFromWindow(HWND hWnd
, DWORD dwFlags
)
149 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
150 return xPRIMARY_MONITOR
;
153 GetWindowPlacement(hWnd
, &wp
) :
154 GetWindowRect(hWnd
, &wp
.rcNormalPosition
)) {
156 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
162 BOOL WINAPI
GetMonitorInfoA(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
166 if ((hMonitor
== xPRIMARY_MONITOR
) &&
168 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
169 SystemParametersInfoA(SPI_GETWORKAREA
, 0, &rcWork
, 0))
171 lpMonitorInfo
->rcMonitor
.left
= 0;
172 lpMonitorInfo
->rcMonitor
.top
= 0;
173 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics(SM_CXSCREEN
);
174 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics(SM_CYSCREEN
);
175 lpMonitorInfo
->rcWork
= rcWork
;
176 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
178 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXA
))
179 lstrcpyA(((MONITORINFOEXA
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
187 BOOL WINAPI
GetMonitorInfoW(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
191 if ((hMonitor
== xPRIMARY_MONITOR
) &&
193 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
194 SystemParametersInfoW(SPI_GETWORKAREA
, 0, &rcWork
, 0))
196 lpMonitorInfo
->rcMonitor
.left
= 0;
197 lpMonitorInfo
->rcMonitor
.top
= 0;
198 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics(SM_CXSCREEN
);
199 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics(SM_CYSCREEN
);
200 lpMonitorInfo
->rcWork
= rcWork
;
201 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
203 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEXW
))
204 lstrcpyW(((MONITORINFOEXW
*)lpMonitorInfo
)->szDevice
, (LPCWSTR
)"D\0I\0S\0P\0L\0A\0Y\0\0");
212 BOOL WINAPI
EnumDisplayMonitors(
213 HDC hdcOptionalForPainting
,
214 LPRECT lprcEnumMonitorsThatIntersect
,
215 MONITORENUMPROC lpfnEnumProc
,
225 rcLimit
.right
= GetSystemMetrics(SM_CXSCREEN
);
226 rcLimit
.bottom
= GetSystemMetrics(SM_CYSCREEN
);
228 if (hdcOptionalForPainting
)
233 switch (GetClipBox(hdcOptionalForPainting
, &rcClip
))
236 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
239 OffsetRect(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
240 if (IntersectRect(&rcLimit
, &rcLimit
, &rcClip
) &&
241 (!lprcEnumMonitorsThatIntersect
||
242 IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
253 if ( lprcEnumMonitorsThatIntersect
&&
254 !IntersectRect(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
262 hdcOptionalForPainting
,