4 * Copyright 1998 Turchanov Sergey
10 /**********************************************************************/
12 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
14 MONITOR MONITOR_PrimaryMonitor
;
16 /***********************************************************************
19 void MONITOR_Initialize(MONITOR
*pMonitor
)
21 pMonitor
->pDriver
->pInitialize(pMonitor
);
24 /***********************************************************************
27 void MONITOR_Finalize(MONITOR
*pMonitor
)
29 pMonitor
->pDriver
->pFinalize(pMonitor
);
32 /***********************************************************************
35 int MONITOR_GetWidth(MONITOR
*pMonitor
)
37 return pMonitor
->pDriver
->pGetWidth(pMonitor
);
40 /***********************************************************************
43 int MONITOR_GetHeight(MONITOR
*pMonitor
)
45 return pMonitor
->pDriver
->pGetHeight(pMonitor
);
48 /***********************************************************************
51 int MONITOR_GetDepth(MONITOR
*pMonitor
)
53 return pMonitor
->pDriver
->pGetDepth(pMonitor
);
56 /**********************************************************************/
58 HMONITOR WINAPI
MonitorFromPoint(POINT32 ptScreenCoords
, DWORD dwFlags
)
60 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
61 ((ptScreenCoords
.x
>= 0) &&
62 (ptScreenCoords
.x
< GetSystemMetrics32(SM_CXSCREEN
)) &&
63 (ptScreenCoords
.y
>= 0) &&
64 (ptScreenCoords
.y
< GetSystemMetrics32(SM_CYSCREEN
))))
66 return xPRIMARY_MONITOR
;
71 HMONITOR WINAPI
MonitorFromRect(LPRECT32 lprcScreenCoords
, DWORD dwFlags
)
73 if ((dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
)) ||
74 ((lprcScreenCoords
->right
> 0) &&
75 (lprcScreenCoords
->bottom
> 0) &&
76 (lprcScreenCoords
->left
< GetSystemMetrics32(SM_CXSCREEN
)) &&
77 (lprcScreenCoords
->top
< GetSystemMetrics32(SM_CYSCREEN
))))
79 return xPRIMARY_MONITOR
;
84 HMONITOR WINAPI
MonitorFromWindow(HWND32 hWnd
, DWORD dwFlags
)
88 if (dwFlags
& (MONITOR_DEFAULTTOPRIMARY
| MONITOR_DEFAULTTONEAREST
))
89 return xPRIMARY_MONITOR
;
91 if (IsIconic32(hWnd
) ?
92 GetWindowPlacement32(hWnd
, &wp
) :
93 GetWindowRect32(hWnd
, &wp
.rcNormalPosition
)) {
95 return MonitorFromRect(&wp
.rcNormalPosition
, dwFlags
);
101 BOOL32 WINAPI
GetMonitorInfo32A(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
105 if ((hMonitor
== xPRIMARY_MONITOR
) &&
107 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
108 SystemParametersInfo32A(SPI_GETWORKAREA
, 0, &rcWork
, 0))
110 lpMonitorInfo
->rcMonitor
.left
= 0;
111 lpMonitorInfo
->rcMonitor
.top
= 0;
112 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics32(SM_CXSCREEN
);
113 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
114 lpMonitorInfo
->rcWork
= rcWork
;
115 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
117 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEX32A
))
118 lstrcpy32A(((MONITORINFOEX32A
*)lpMonitorInfo
)->szDevice
, "DISPLAY");
126 BOOL32 WINAPI
GetMonitorInfo32W(HMONITOR hMonitor
, LPMONITORINFO lpMonitorInfo
)
130 if ((hMonitor
== xPRIMARY_MONITOR
) &&
132 (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFO
)) &&
133 SystemParametersInfo32W(SPI_GETWORKAREA
, 0, &rcWork
, 0))
135 lpMonitorInfo
->rcMonitor
.left
= 0;
136 lpMonitorInfo
->rcMonitor
.top
= 0;
137 lpMonitorInfo
->rcMonitor
.right
= GetSystemMetrics32(SM_CXSCREEN
);
138 lpMonitorInfo
->rcMonitor
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
139 lpMonitorInfo
->rcWork
= rcWork
;
140 lpMonitorInfo
->dwFlags
= MONITORINFOF_PRIMARY
;
142 if (lpMonitorInfo
->cbSize
>= sizeof(MONITORINFOEX32W
))
143 lstrcpy32W(((MONITORINFOEX32W
*)lpMonitorInfo
)->szDevice
, (LPCWSTR
)"D\0I\0S\0P\0L\0A\0Y\0\0");
151 BOOL32 WINAPI
EnumDisplayMonitors(
152 HDC32 hdcOptionalForPainting
,
153 LPRECT32 lprcEnumMonitorsThatIntersect
,
154 MONITORENUMPROC lpfnEnumProc
,
164 rcLimit
.right
= GetSystemMetrics32(SM_CXSCREEN
);
165 rcLimit
.bottom
= GetSystemMetrics32(SM_CYSCREEN
);
167 if (hdcOptionalForPainting
)
172 switch (GetClipBox32(hdcOptionalForPainting
, &rcClip
))
175 if (!GetDCOrgEx(hdcOptionalForPainting
, &ptOrg
))
178 OffsetRect32(&rcLimit
, -ptOrg
.x
, -ptOrg
.y
);
179 if (IntersectRect32(&rcLimit
, &rcLimit
, &rcClip
) &&
180 (!lprcEnumMonitorsThatIntersect
||
181 IntersectRect32(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
))) {
192 if ( lprcEnumMonitorsThatIntersect
&&
193 !IntersectRect32(&rcLimit
, &rcLimit
, lprcEnumMonitorsThatIntersect
)) {
201 hdcOptionalForPainting
,