annotate lib/legacy_dx/multimon.h @ 1952:4ed7d18abe93

pActorBuffs[8] to pActorBuffs[ACTOR_BUFF_SOMETHING_THAT_HALVES_AC]
author Grumpy7
date Fri, 25 Oct 2013 11:14:32 -0700
parents 9c0607679772
children
rev   line source
0
Ritor1
parents:
diff changeset
1 //=============================================================================
Ritor1
parents:
diff changeset
2 //
Ritor1
parents:
diff changeset
3 // multimon.h -- Stub module that fakes multiple monitor apis on Win32 OSes
Ritor1
parents:
diff changeset
4 // without them.
Ritor1
parents:
diff changeset
5 //
Ritor1
parents:
diff changeset
6 // By using this header your code will get back default values from
Ritor1
parents:
diff changeset
7 // GetSystemMetrics() for new metrics, and the new multimonitor APIs
Ritor1
parents:
diff changeset
8 // will act like only one display is present on a Win32 OS without
Ritor1
parents:
diff changeset
9 // multimonitor APIs.
Ritor1
parents:
diff changeset
10 //
Ritor1
parents:
diff changeset
11 // Exactly one source must include this with COMPILE_MULTIMON_STUBS defined.
Ritor1
parents:
diff changeset
12 //
Ritor1
parents:
diff changeset
13 // Copyright (c) Microsoft Corporation. All rights reserved.
Ritor1
parents:
diff changeset
14 //
Ritor1
parents:
diff changeset
15 //=============================================================================
Ritor1
parents:
diff changeset
16
Ritor1
parents:
diff changeset
17 #ifdef __cplusplus
Ritor1
parents:
diff changeset
18 extern "C" { // Assume C declarations for C++
Ritor1
parents:
diff changeset
19 #endif // __cplusplus
Ritor1
parents:
diff changeset
20
Ritor1
parents:
diff changeset
21 //
Ritor1
parents:
diff changeset
22 // If we are building with Win95/NT4 headers, we need to declare
Ritor1
parents:
diff changeset
23 // the multimonitor-related metrics and APIs ourselves.
Ritor1
parents:
diff changeset
24 //
Ritor1
parents:
diff changeset
25 #ifndef SM_CMONITORS
Ritor1
parents:
diff changeset
26
Ritor1
parents:
diff changeset
27 #define SM_XVIRTUALSCREEN 76
Ritor1
parents:
diff changeset
28 #define SM_YVIRTUALSCREEN 77
Ritor1
parents:
diff changeset
29 #define SM_CXVIRTUALSCREEN 78
Ritor1
parents:
diff changeset
30 #define SM_CYVIRTUALSCREEN 79
Ritor1
parents:
diff changeset
31 #define SM_CMONITORS 80
Ritor1
parents:
diff changeset
32 #define SM_SAMEDISPLAYFORMAT 81
Ritor1
parents:
diff changeset
33
Ritor1
parents:
diff changeset
34 // HMONITOR is already declared if WINVER >= 0x0500 in windef.h
Ritor1
parents:
diff changeset
35 // This is for components built with an older version number.
Ritor1
parents:
diff changeset
36 //
Ritor1
parents:
diff changeset
37 #if !defined(HMONITOR_DECLARED) && (WINVER < 0x0500)
Ritor1
parents:
diff changeset
38 DECLARE_HANDLE(HMONITOR);
Ritor1
parents:
diff changeset
39 #define HMONITOR_DECLARED
Ritor1
parents:
diff changeset
40 #endif
Ritor1
parents:
diff changeset
41
Ritor1
parents:
diff changeset
42 #define MONITOR_DEFAULTTONULL 0x00000000
Ritor1
parents:
diff changeset
43 #define MONITOR_DEFAULTTOPRIMARY 0x00000001
Ritor1
parents:
diff changeset
44 #define MONITOR_DEFAULTTONEAREST 0x00000002
Ritor1
parents:
diff changeset
45
Ritor1
parents:
diff changeset
46 #define MONITORINFOF_PRIMARY 0x00000001
Ritor1
parents:
diff changeset
47
Ritor1
parents:
diff changeset
48 typedef struct tagMONITORINFO
Ritor1
parents:
diff changeset
49 {
Ritor1
parents:
diff changeset
50 DWORD cbSize;
Ritor1
parents:
diff changeset
51 RECT rcMonitor;
Ritor1
parents:
diff changeset
52 RECT rcWork;
Ritor1
parents:
diff changeset
53 DWORD dwFlags;
Ritor1
parents:
diff changeset
54 } MONITORINFO, *LPMONITORINFO;
Ritor1
parents:
diff changeset
55
Ritor1
parents:
diff changeset
56 #ifndef CCHDEVICENAME
Ritor1
parents:
diff changeset
57 #define CCHDEVICENAME 32
Ritor1
parents:
diff changeset
58 #endif
Ritor1
parents:
diff changeset
59
Ritor1
parents:
diff changeset
60 #ifdef __cplusplus
Ritor1
parents:
diff changeset
61 typedef struct tagMONITORINFOEXA : public tagMONITORINFO
Ritor1
parents:
diff changeset
62 {
Ritor1
parents:
diff changeset
63 CHAR szDevice[CCHDEVICENAME];
Ritor1
parents:
diff changeset
64 } MONITORINFOEXA, *LPMONITORINFOEXA;
Ritor1
parents:
diff changeset
65 typedef struct tagMONITORINFOEXW : public tagMONITORINFO
Ritor1
parents:
diff changeset
66 {
Ritor1
parents:
diff changeset
67 WCHAR szDevice[CCHDEVICENAME];
Ritor1
parents:
diff changeset
68 } MONITORINFOEXW, *LPMONITORINFOEXW;
Ritor1
parents:
diff changeset
69 #ifdef UNICODE
Ritor1
parents:
diff changeset
70 typedef MONITORINFOEXW MONITORINFOEX;
Ritor1
parents:
diff changeset
71 typedef LPMONITORINFOEXW LPMONITORINFOEX;
Ritor1
parents:
diff changeset
72 #else
Ritor1
parents:
diff changeset
73 typedef MONITORINFOEXA MONITORINFOEX;
Ritor1
parents:
diff changeset
74 typedef LPMONITORINFOEXA LPMONITORINFOEX;
Ritor1
parents:
diff changeset
75 #endif // UNICODE
Ritor1
parents:
diff changeset
76 #else // ndef __cplusplus
Ritor1
parents:
diff changeset
77 typedef struct tagMONITORINFOEXA
Ritor1
parents:
diff changeset
78 {
Ritor1
parents:
diff changeset
79 MONITORINFO;
Ritor1
parents:
diff changeset
80 CHAR szDevice[CCHDEVICENAME];
Ritor1
parents:
diff changeset
81 } MONITORINFOEXA, *LPMONITORINFOEXA;
Ritor1
parents:
diff changeset
82 typedef struct tagMONITORINFOEXW
Ritor1
parents:
diff changeset
83 {
Ritor1
parents:
diff changeset
84 MONITORINFO;
Ritor1
parents:
diff changeset
85 WCHAR szDevice[CCHDEVICENAME];
Ritor1
parents:
diff changeset
86 } MONITORINFOEXW, *LPMONITORINFOEXW;
Ritor1
parents:
diff changeset
87 #ifdef UNICODE
Ritor1
parents:
diff changeset
88 typedef MONITORINFOEXW MONITORINFOEX;
Ritor1
parents:
diff changeset
89 typedef LPMONITORINFOEXW LPMONITORINFOEX;
Ritor1
parents:
diff changeset
90 #else
Ritor1
parents:
diff changeset
91 typedef MONITORINFOEXA MONITORINFOEX;
Ritor1
parents:
diff changeset
92 typedef LPMONITORINFOEXA LPMONITORINFOEX;
Ritor1
parents:
diff changeset
93 #endif // UNICODE
Ritor1
parents:
diff changeset
94 #endif
Ritor1
parents:
diff changeset
95
Ritor1
parents:
diff changeset
96 typedef BOOL (CALLBACK* MONITORENUMPROC)(HMONITOR, HDC, LPRECT, LPARAM);
Ritor1
parents:
diff changeset
97
Ritor1
parents:
diff changeset
98 #ifndef DISPLAY_DEVICE_ATTACHED_TO_DESKTOP
Ritor1
parents:
diff changeset
99 typedef struct _DISPLAY_DEVICEA {
Ritor1
parents:
diff changeset
100 DWORD cb;
Ritor1
parents:
diff changeset
101 CHAR DeviceName[32];
Ritor1
parents:
diff changeset
102 CHAR DeviceString[128];
Ritor1
parents:
diff changeset
103 DWORD StateFlags;
Ritor1
parents:
diff changeset
104 CHAR DeviceID[128];
Ritor1
parents:
diff changeset
105 CHAR DeviceKey[128];
Ritor1
parents:
diff changeset
106 } DISPLAY_DEVICEA, *PDISPLAY_DEVICEA, *LPDISPLAY_DEVICEA;
Ritor1
parents:
diff changeset
107 typedef struct _DISPLAY_DEVICEW {
Ritor1
parents:
diff changeset
108 DWORD cb;
Ritor1
parents:
diff changeset
109 WCHAR DeviceName[32];
Ritor1
parents:
diff changeset
110 WCHAR DeviceString[128];
Ritor1
parents:
diff changeset
111 DWORD StateFlags;
Ritor1
parents:
diff changeset
112 WCHAR DeviceID[128];
Ritor1
parents:
diff changeset
113 WCHAR DeviceKey[128];
Ritor1
parents:
diff changeset
114 } DISPLAY_DEVICEW, *PDISPLAY_DEVICEW, *LPDISPLAY_DEVICEW;
Ritor1
parents:
diff changeset
115 #ifdef UNICODE
Ritor1
parents:
diff changeset
116 typedef DISPLAY_DEVICEW DISPLAY_DEVICE;
Ritor1
parents:
diff changeset
117 typedef PDISPLAY_DEVICEW PDISPLAY_DEVICE;
Ritor1
parents:
diff changeset
118 typedef LPDISPLAY_DEVICEW LPDISPLAY_DEVICE;
Ritor1
parents:
diff changeset
119 #else
Ritor1
parents:
diff changeset
120 typedef DISPLAY_DEVICEA DISPLAY_DEVICE;
Ritor1
parents:
diff changeset
121 typedef PDISPLAY_DEVICEA PDISPLAY_DEVICE;
Ritor1
parents:
diff changeset
122 typedef LPDISPLAY_DEVICEA LPDISPLAY_DEVICE;
Ritor1
parents:
diff changeset
123 #endif // UNICODE
Ritor1
parents:
diff changeset
124
Ritor1
parents:
diff changeset
125 #define DISPLAY_DEVICE_ATTACHED_TO_DESKTOP 0x00000001
Ritor1
parents:
diff changeset
126 #define DISPLAY_DEVICE_MULTI_DRIVER 0x00000002
Ritor1
parents:
diff changeset
127 #define DISPLAY_DEVICE_PRIMARY_DEVICE 0x00000004
Ritor1
parents:
diff changeset
128 #define DISPLAY_DEVICE_MIRRORING_DRIVER 0x00000008
Ritor1
parents:
diff changeset
129 #define DISPLAY_DEVICE_VGA_COMPATIBLE 0x00000010
Ritor1
parents:
diff changeset
130 #endif
Ritor1
parents:
diff changeset
131
Ritor1
parents:
diff changeset
132 #endif // SM_CMONITORS
Ritor1
parents:
diff changeset
133
Ritor1
parents:
diff changeset
134 #undef GetMonitorInfo
Ritor1
parents:
diff changeset
135 #undef GetSystemMetrics
Ritor1
parents:
diff changeset
136 #undef MonitorFromWindow
Ritor1
parents:
diff changeset
137 #undef MonitorFromRect
Ritor1
parents:
diff changeset
138 #undef MonitorFromPoint
Ritor1
parents:
diff changeset
139 #undef EnumDisplayMonitors
Ritor1
parents:
diff changeset
140 #undef EnumDisplayDevices
Ritor1
parents:
diff changeset
141
Ritor1
parents:
diff changeset
142 //
Ritor1
parents:
diff changeset
143 // Define COMPILE_MULTIMON_STUBS to compile the stubs;
Ritor1
parents:
diff changeset
144 // otherwise, you get the declarations.
Ritor1
parents:
diff changeset
145 //
Ritor1
parents:
diff changeset
146 #ifdef COMPILE_MULTIMON_STUBS
Ritor1
parents:
diff changeset
147
Ritor1
parents:
diff changeset
148 //-----------------------------------------------------------------------------
Ritor1
parents:
diff changeset
149 //
Ritor1
parents:
diff changeset
150 // Implement the API stubs.
Ritor1
parents:
diff changeset
151 //
Ritor1
parents:
diff changeset
152 //-----------------------------------------------------------------------------
Ritor1
parents:
diff changeset
153
Ritor1
parents:
diff changeset
154 #ifndef MULTIMON_FNS_DEFINED
Ritor1
parents:
diff changeset
155
Ritor1
parents:
diff changeset
156 int (WINAPI* g_pfnGetSystemMetrics)(int) = NULL;
Ritor1
parents:
diff changeset
157 HMONITOR (WINAPI* g_pfnMonitorFromWindow)(HWND, DWORD) = NULL;
Ritor1
parents:
diff changeset
158 HMONITOR (WINAPI* g_pfnMonitorFromRect)(LPCRECT, DWORD) = NULL;
Ritor1
parents:
diff changeset
159 HMONITOR (WINAPI* g_pfnMonitorFromPoint)(POINT, DWORD) = NULL;
Ritor1
parents:
diff changeset
160 BOOL (WINAPI* g_pfnGetMonitorInfo)(HMONITOR, LPMONITORINFO) = NULL;
Ritor1
parents:
diff changeset
161 BOOL (WINAPI* g_pfnEnumDisplayMonitors)(HDC, LPCRECT, MONITORENUMPROC, LPARAM) = NULL;
Ritor1
parents:
diff changeset
162 BOOL (WINAPI* g_pfnEnumDisplayDevices)(PVOID, DWORD, PDISPLAY_DEVICE,DWORD) = NULL;
Ritor1
parents:
diff changeset
163 BOOL g_fMultiMonInitDone = FALSE;
Ritor1
parents:
diff changeset
164 BOOL g_fMultimonPlatformNT = FALSE;
Ritor1
parents:
diff changeset
165
Ritor1
parents:
diff changeset
166 #endif
Ritor1
parents:
diff changeset
167
Ritor1
parents:
diff changeset
168 BOOL IsPlatformNT()
Ritor1
parents:
diff changeset
169 {
Ritor1
parents:
diff changeset
170 OSVERSIONINFOA osvi = {0};
Ritor1
parents:
diff changeset
171 osvi.dwOSVersionInfoSize = sizeof(osvi);
Ritor1
parents:
diff changeset
172 GetVersionExA((OSVERSIONINFOA*)&osvi);
Ritor1
parents:
diff changeset
173 return (VER_PLATFORM_WIN32_NT == osvi.dwPlatformId);
Ritor1
parents:
diff changeset
174 }
Ritor1
parents:
diff changeset
175
Ritor1
parents:
diff changeset
176 BOOL InitMultipleMonitorStubs(void)
Ritor1
parents:
diff changeset
177 {
Ritor1
parents:
diff changeset
178 HMODULE hUser32;
Ritor1
parents:
diff changeset
179 if (g_fMultiMonInitDone)
Ritor1
parents:
diff changeset
180 {
Ritor1
parents:
diff changeset
181 return g_pfnGetMonitorInfo != NULL;
Ritor1
parents:
diff changeset
182 }
Ritor1
parents:
diff changeset
183
Ritor1
parents:
diff changeset
184 g_fMultimonPlatformNT = IsPlatformNT();
Ritor1
parents:
diff changeset
185 hUser32 = GetModuleHandle(TEXT("USER32"));
Ritor1
parents:
diff changeset
186 if (hUser32 &&
Ritor1
parents:
diff changeset
187 (*(FARPROC*)&g_pfnGetSystemMetrics = GetProcAddress(hUser32,"GetSystemMetrics")) != NULL &&
Ritor1
parents:
diff changeset
188 (*(FARPROC*)&g_pfnMonitorFromWindow = GetProcAddress(hUser32,"MonitorFromWindow")) != NULL &&
Ritor1
parents:
diff changeset
189 (*(FARPROC*)&g_pfnMonitorFromRect = GetProcAddress(hUser32,"MonitorFromRect")) != NULL &&
Ritor1
parents:
diff changeset
190 (*(FARPROC*)&g_pfnMonitorFromPoint = GetProcAddress(hUser32,"MonitorFromPoint")) != NULL &&
Ritor1
parents:
diff changeset
191 (*(FARPROC*)&g_pfnEnumDisplayMonitors = GetProcAddress(hUser32,"EnumDisplayMonitors")) != NULL &&
Ritor1
parents:
diff changeset
192 #ifdef UNICODE
Ritor1
parents:
diff changeset
193 (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesW")) != NULL &&
Ritor1
parents:
diff changeset
194 (*(FARPROC*)&g_pfnGetMonitorInfo = g_fMultimonPlatformNT ? GetProcAddress(hUser32,"GetMonitorInfoW") :
Ritor1
parents:
diff changeset
195 GetProcAddress(hUser32,"GetMonitorInfoA")) != NULL
Ritor1
parents:
diff changeset
196 #else
Ritor1
parents:
diff changeset
197 (*(FARPROC*)&g_pfnGetMonitorInfo = GetProcAddress(hUser32,"GetMonitorInfoA")) != NULL &&
Ritor1
parents:
diff changeset
198 (*(FARPROC*)&g_pfnEnumDisplayDevices = GetProcAddress(hUser32,"EnumDisplayDevicesA")) != NULL
Ritor1
parents:
diff changeset
199 #endif
Ritor1
parents:
diff changeset
200 ) {
Ritor1
parents:
diff changeset
201 g_fMultiMonInitDone = TRUE;
Ritor1
parents:
diff changeset
202 return TRUE;
Ritor1
parents:
diff changeset
203 }
Ritor1
parents:
diff changeset
204 else
Ritor1
parents:
diff changeset
205 {
Ritor1
parents:
diff changeset
206 g_pfnGetSystemMetrics = NULL;
Ritor1
parents:
diff changeset
207 g_pfnMonitorFromWindow = NULL;
Ritor1
parents:
diff changeset
208 g_pfnMonitorFromRect = NULL;
Ritor1
parents:
diff changeset
209 g_pfnMonitorFromPoint = NULL;
Ritor1
parents:
diff changeset
210 g_pfnGetMonitorInfo = NULL;
Ritor1
parents:
diff changeset
211 g_pfnEnumDisplayMonitors = NULL;
Ritor1
parents:
diff changeset
212 g_pfnEnumDisplayDevices = NULL;
Ritor1
parents:
diff changeset
213
Ritor1
parents:
diff changeset
214 g_fMultiMonInitDone = TRUE;
Ritor1
parents:
diff changeset
215 return FALSE;
Ritor1
parents:
diff changeset
216 }
Ritor1
parents:
diff changeset
217 }
Ritor1
parents:
diff changeset
218
Ritor1
parents:
diff changeset
219 //-----------------------------------------------------------------------------
Ritor1
parents:
diff changeset
220 //
Ritor1
parents:
diff changeset
221 // fake implementations of Monitor APIs that work with the primary display
Ritor1
parents:
diff changeset
222 // no special parameter validation is made since these run in client code
Ritor1
parents:
diff changeset
223 //
Ritor1
parents:
diff changeset
224 //-----------------------------------------------------------------------------
Ritor1
parents:
diff changeset
225
Ritor1
parents:
diff changeset
226 int WINAPI
Ritor1
parents:
diff changeset
227 xGetSystemMetrics(int nIndex)
Ritor1
parents:
diff changeset
228 {
Ritor1
parents:
diff changeset
229 if (InitMultipleMonitorStubs())
Ritor1
parents:
diff changeset
230 return g_pfnGetSystemMetrics(nIndex);
Ritor1
parents:
diff changeset
231
Ritor1
parents:
diff changeset
232 switch (nIndex)
Ritor1
parents:
diff changeset
233 {
Ritor1
parents:
diff changeset
234 case SM_CMONITORS:
Ritor1
parents:
diff changeset
235 case SM_SAMEDISPLAYFORMAT:
Ritor1
parents:
diff changeset
236 return 1;
Ritor1
parents:
diff changeset
237
Ritor1
parents:
diff changeset
238 case SM_XVIRTUALSCREEN:
Ritor1
parents:
diff changeset
239 case SM_YVIRTUALSCREEN:
Ritor1
parents:
diff changeset
240 return 0;
Ritor1
parents:
diff changeset
241
Ritor1
parents:
diff changeset
242 case SM_CXVIRTUALSCREEN:
Ritor1
parents:
diff changeset
243 nIndex = SM_CXSCREEN;
Ritor1
parents:
diff changeset
244 break;
Ritor1
parents:
diff changeset
245
Ritor1
parents:
diff changeset
246 case SM_CYVIRTUALSCREEN:
Ritor1
parents:
diff changeset
247 nIndex = SM_CYSCREEN;
Ritor1
parents:
diff changeset
248 break;
Ritor1
parents:
diff changeset
249 }
Ritor1
parents:
diff changeset
250
Ritor1
parents:
diff changeset
251 return GetSystemMetrics(nIndex);
Ritor1
parents:
diff changeset
252 }
Ritor1
parents:
diff changeset
253
Ritor1
parents:
diff changeset
254 #define xPRIMARY_MONITOR ((HMONITOR)0x12340042)
Ritor1
parents:
diff changeset
255
Ritor1
parents:
diff changeset
256 HMONITOR WINAPI
Ritor1
parents:
diff changeset
257 xMonitorFromPoint(POINT ptScreenCoords, DWORD dwFlags)
Ritor1
parents:
diff changeset
258 {
Ritor1
parents:
diff changeset
259 if (InitMultipleMonitorStubs())
Ritor1
parents:
diff changeset
260 return g_pfnMonitorFromPoint(ptScreenCoords, dwFlags);
Ritor1
parents:
diff changeset
261
Ritor1
parents:
diff changeset
262 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
Ritor1
parents:
diff changeset
263 ((ptScreenCoords.x >= 0) &&
Ritor1
parents:
diff changeset
264 (ptScreenCoords.x < GetSystemMetrics(SM_CXSCREEN)) &&
Ritor1
parents:
diff changeset
265 (ptScreenCoords.y >= 0) &&
Ritor1
parents:
diff changeset
266 (ptScreenCoords.y < GetSystemMetrics(SM_CYSCREEN))))
Ritor1
parents:
diff changeset
267 {
Ritor1
parents:
diff changeset
268 return xPRIMARY_MONITOR;
Ritor1
parents:
diff changeset
269 }
Ritor1
parents:
diff changeset
270
Ritor1
parents:
diff changeset
271 return NULL;
Ritor1
parents:
diff changeset
272 }
Ritor1
parents:
diff changeset
273
Ritor1
parents:
diff changeset
274 HMONITOR WINAPI
Ritor1
parents:
diff changeset
275 xMonitorFromRect(LPCRECT lprcScreenCoords, DWORD dwFlags)
Ritor1
parents:
diff changeset
276 {
Ritor1
parents:
diff changeset
277 if (InitMultipleMonitorStubs())
Ritor1
parents:
diff changeset
278 return g_pfnMonitorFromRect(lprcScreenCoords, dwFlags);
Ritor1
parents:
diff changeset
279
Ritor1
parents:
diff changeset
280 if ((dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST)) ||
Ritor1
parents:
diff changeset
281 ((lprcScreenCoords->right > 0) &&
Ritor1
parents:
diff changeset
282 (lprcScreenCoords->bottom > 0) &&
Ritor1
parents:
diff changeset
283 (lprcScreenCoords->left < GetSystemMetrics(SM_CXSCREEN)) &&
Ritor1
parents:
diff changeset
284 (lprcScreenCoords->top < GetSystemMetrics(SM_CYSCREEN))))
Ritor1
parents:
diff changeset
285 {
Ritor1
parents:
diff changeset
286 return xPRIMARY_MONITOR;
Ritor1
parents:
diff changeset
287 }
Ritor1
parents:
diff changeset
288
Ritor1
parents:
diff changeset
289 return NULL;
Ritor1
parents:
diff changeset
290 }
Ritor1
parents:
diff changeset
291
Ritor1
parents:
diff changeset
292 HMONITOR WINAPI
Ritor1
parents:
diff changeset
293 xMonitorFromWindow(HWND hWnd, DWORD dwFlags)
Ritor1
parents:
diff changeset
294 {
Ritor1
parents:
diff changeset
295 WINDOWPLACEMENT wp;
Ritor1
parents:
diff changeset
296
Ritor1
parents:
diff changeset
297 if (InitMultipleMonitorStubs())
Ritor1
parents:
diff changeset
298 return g_pfnMonitorFromWindow(hWnd, dwFlags);
Ritor1
parents:
diff changeset
299
Ritor1
parents:
diff changeset
300 if (dwFlags & (MONITOR_DEFAULTTOPRIMARY | MONITOR_DEFAULTTONEAREST))
Ritor1
parents:
diff changeset
301 return xPRIMARY_MONITOR;
Ritor1
parents:
diff changeset
302
Ritor1
parents:
diff changeset
303 if (IsIconic(hWnd) ?
Ritor1
parents:
diff changeset
304 GetWindowPlacement(hWnd, &wp) :
Ritor1
parents:
diff changeset
305 GetWindowRect(hWnd, &wp.rcNormalPosition)) {
Ritor1
parents:
diff changeset
306
Ritor1
parents:
diff changeset
307 return xMonitorFromRect(&wp.rcNormalPosition, dwFlags);
Ritor1
parents:
diff changeset
308 }
Ritor1
parents:
diff changeset
309
Ritor1
parents:
diff changeset
310 return NULL;
Ritor1
parents:
diff changeset
311 }
Ritor1
parents:
diff changeset
312
Ritor1
parents:
diff changeset
313 BOOL WINAPI
Ritor1
parents:
diff changeset
314 xGetMonitorInfo(HMONITOR hMonitor, LPMONITORINFO lpMonitorInfo)
Ritor1
parents:
diff changeset
315 {
Ritor1
parents:
diff changeset
316 RECT rcWork;
Ritor1
parents:
diff changeset
317
Ritor1
parents:
diff changeset
318 if (InitMultipleMonitorStubs())
Ritor1
parents:
diff changeset
319 {
Ritor1
parents:
diff changeset
320 BOOL f = g_pfnGetMonitorInfo(hMonitor, lpMonitorInfo);
Ritor1
parents:
diff changeset
321 #ifdef UNICODE
Ritor1
parents:
diff changeset
322 if (f && !g_fMultimonPlatformNT && (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX)))
Ritor1
parents:
diff changeset
323 {
Ritor1
parents:
diff changeset
324 MultiByteToWideChar(CP_ACP, 0,
Ritor1
parents:
diff changeset
325 (LPSTR)((MONITORINFOEX*)lpMonitorInfo)->szDevice, -1,
Ritor1
parents:
diff changeset
326 ((MONITORINFOEX*)lpMonitorInfo)->szDevice, (sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR)));
Ritor1
parents:
diff changeset
327 }
Ritor1
parents:
diff changeset
328 #endif
Ritor1
parents:
diff changeset
329 return f;
Ritor1
parents:
diff changeset
330 }
Ritor1
parents:
diff changeset
331
Ritor1
parents:
diff changeset
332 if ((hMonitor == xPRIMARY_MONITOR) &&
Ritor1
parents:
diff changeset
333 lpMonitorInfo &&
Ritor1
parents:
diff changeset
334 (lpMonitorInfo->cbSize >= sizeof(MONITORINFO)) &&
Ritor1
parents:
diff changeset
335 SystemParametersInfoA(SPI_GETWORKAREA, 0, &rcWork, 0))
Ritor1
parents:
diff changeset
336 {
Ritor1
parents:
diff changeset
337 lpMonitorInfo->rcMonitor.left = 0;
Ritor1
parents:
diff changeset
338 lpMonitorInfo->rcMonitor.top = 0;
Ritor1
parents:
diff changeset
339 lpMonitorInfo->rcMonitor.right = GetSystemMetrics(SM_CXSCREEN);
Ritor1
parents:
diff changeset
340 lpMonitorInfo->rcMonitor.bottom = GetSystemMetrics(SM_CYSCREEN);
Ritor1
parents:
diff changeset
341 lpMonitorInfo->rcWork = rcWork;
Ritor1
parents:
diff changeset
342 lpMonitorInfo->dwFlags = MONITORINFOF_PRIMARY;
Ritor1
parents:
diff changeset
343
Ritor1
parents:
diff changeset
344 if (lpMonitorInfo->cbSize >= sizeof(MONITORINFOEX))
Ritor1
parents:
diff changeset
345 {
Ritor1
parents:
diff changeset
346 #ifdef UNICODE
Ritor1
parents:
diff changeset
347 MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, ((MONITORINFOEX*)lpMonitorInfo)->szDevice, (sizeof(((MONITORINFOEX*)lpMonitorInfo)->szDevice)/sizeof(TCHAR)));
Ritor1
parents:
diff changeset
348 #else // UNICODE
Ritor1
parents:
diff changeset
349 lstrcpy(((MONITORINFOEX*)lpMonitorInfo)->szDevice, TEXT("DISPLAY"));
Ritor1
parents:
diff changeset
350 #endif // UNICODE
Ritor1
parents:
diff changeset
351 }
Ritor1
parents:
diff changeset
352
Ritor1
parents:
diff changeset
353 return TRUE;
Ritor1
parents:
diff changeset
354 }
Ritor1
parents:
diff changeset
355
Ritor1
parents:
diff changeset
356 return FALSE;
Ritor1
parents:
diff changeset
357 }
Ritor1
parents:
diff changeset
358
Ritor1
parents:
diff changeset
359 BOOL WINAPI
Ritor1
parents:
diff changeset
360 xEnumDisplayMonitors(
Ritor1
parents:
diff changeset
361 HDC hdcOptionalForPainting,
Ritor1
parents:
diff changeset
362 LPCRECT lprcEnumMonitorsThatIntersect,
Ritor1
parents:
diff changeset
363 MONITORENUMPROC lpfnEnumProc,
Ritor1
parents:
diff changeset
364 LPARAM dwData)
Ritor1
parents:
diff changeset
365 {
Ritor1
parents:
diff changeset
366 RECT rcLimit;
Ritor1
parents:
diff changeset
367
Ritor1
parents:
diff changeset
368 if (InitMultipleMonitorStubs()) {
Ritor1
parents:
diff changeset
369 return g_pfnEnumDisplayMonitors(
Ritor1
parents:
diff changeset
370 hdcOptionalForPainting,
Ritor1
parents:
diff changeset
371 lprcEnumMonitorsThatIntersect,
Ritor1
parents:
diff changeset
372 lpfnEnumProc,
Ritor1
parents:
diff changeset
373 dwData);
Ritor1
parents:
diff changeset
374 }
Ritor1
parents:
diff changeset
375
Ritor1
parents:
diff changeset
376 if (!lpfnEnumProc)
Ritor1
parents:
diff changeset
377 return FALSE;
Ritor1
parents:
diff changeset
378
Ritor1
parents:
diff changeset
379 rcLimit.left = 0;
Ritor1
parents:
diff changeset
380 rcLimit.top = 0;
Ritor1
parents:
diff changeset
381 rcLimit.right = GetSystemMetrics(SM_CXSCREEN);
Ritor1
parents:
diff changeset
382 rcLimit.bottom = GetSystemMetrics(SM_CYSCREEN);
Ritor1
parents:
diff changeset
383
Ritor1
parents:
diff changeset
384 if (hdcOptionalForPainting)
Ritor1
parents:
diff changeset
385 {
Ritor1
parents:
diff changeset
386 RECT rcClip;
Ritor1
parents:
diff changeset
387 POINT ptOrg;
Ritor1
parents:
diff changeset
388
Ritor1
parents:
diff changeset
389 switch (GetClipBox(hdcOptionalForPainting, &rcClip))
Ritor1
parents:
diff changeset
390 {
Ritor1
parents:
diff changeset
391 default:
Ritor1
parents:
diff changeset
392 if (!GetDCOrgEx(hdcOptionalForPainting, &ptOrg))
Ritor1
parents:
diff changeset
393 return FALSE;
Ritor1
parents:
diff changeset
394
Ritor1
parents:
diff changeset
395 OffsetRect(&rcLimit, -ptOrg.x, -ptOrg.y);
Ritor1
parents:
diff changeset
396 if (IntersectRect(&rcLimit, &rcLimit, &rcClip) &&
Ritor1
parents:
diff changeset
397 (!lprcEnumMonitorsThatIntersect ||
Ritor1
parents:
diff changeset
398 IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect))) {
Ritor1
parents:
diff changeset
399
Ritor1
parents:
diff changeset
400 break;
Ritor1
parents:
diff changeset
401 }
Ritor1
parents:
diff changeset
402 //fall thru
Ritor1
parents:
diff changeset
403 case NULLREGION:
Ritor1
parents:
diff changeset
404 return TRUE;
Ritor1
parents:
diff changeset
405 case ERROR:
Ritor1
parents:
diff changeset
406 return FALSE;
Ritor1
parents:
diff changeset
407 }
Ritor1
parents:
diff changeset
408 } else {
Ritor1
parents:
diff changeset
409 if ( lprcEnumMonitorsThatIntersect &&
Ritor1
parents:
diff changeset
410 !IntersectRect(&rcLimit, &rcLimit, lprcEnumMonitorsThatIntersect)) {
Ritor1
parents:
diff changeset
411
Ritor1
parents:
diff changeset
412 return TRUE;
Ritor1
parents:
diff changeset
413 }
Ritor1
parents:
diff changeset
414 }
Ritor1
parents:
diff changeset
415
Ritor1
parents:
diff changeset
416 return lpfnEnumProc(
Ritor1
parents:
diff changeset
417 xPRIMARY_MONITOR,
Ritor1
parents:
diff changeset
418 hdcOptionalForPainting,
Ritor1
parents:
diff changeset
419 &rcLimit,
Ritor1
parents:
diff changeset
420 dwData);
Ritor1
parents:
diff changeset
421 }
Ritor1
parents:
diff changeset
422
Ritor1
parents:
diff changeset
423 BOOL WINAPI
Ritor1
parents:
diff changeset
424 xEnumDisplayDevices(
Ritor1
parents:
diff changeset
425 PVOID Unused,
Ritor1
parents:
diff changeset
426 DWORD iDevNum,
Ritor1
parents:
diff changeset
427 PDISPLAY_DEVICE lpDisplayDevice,
Ritor1
parents:
diff changeset
428 DWORD dwFlags)
Ritor1
parents:
diff changeset
429 {
Ritor1
parents:
diff changeset
430 if (InitMultipleMonitorStubs())
Ritor1
parents:
diff changeset
431 return g_pfnEnumDisplayDevices(Unused, iDevNum, lpDisplayDevice, dwFlags);
Ritor1
parents:
diff changeset
432
Ritor1
parents:
diff changeset
433 if (Unused != NULL)
Ritor1
parents:
diff changeset
434 return FALSE;
Ritor1
parents:
diff changeset
435
Ritor1
parents:
diff changeset
436 if (iDevNum != 0)
Ritor1
parents:
diff changeset
437 return FALSE;
Ritor1
parents:
diff changeset
438
Ritor1
parents:
diff changeset
439 if (lpDisplayDevice == NULL || lpDisplayDevice->cb < sizeof(DISPLAY_DEVICE))
Ritor1
parents:
diff changeset
440 return FALSE;
Ritor1
parents:
diff changeset
441
Ritor1
parents:
diff changeset
442 #ifdef UNICODE
Ritor1
parents:
diff changeset
443 MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, lpDisplayDevice->DeviceName, (sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR)));
Ritor1
parents:
diff changeset
444 MultiByteToWideChar(CP_ACP, 0, "DISPLAY", -1, lpDisplayDevice->DeviceString, (sizeof(lpDisplayDevice->DeviceName)/sizeof(TCHAR)));
Ritor1
parents:
diff changeset
445 #else // UNICODE
Ritor1
parents:
diff changeset
446 lstrcpy((LPTSTR)lpDisplayDevice->DeviceName, TEXT("DISPLAY"));
Ritor1
parents:
diff changeset
447 lstrcpy((LPTSTR)lpDisplayDevice->DeviceString, TEXT("DISPLAY"));
Ritor1
parents:
diff changeset
448 #endif // UNICODE
Ritor1
parents:
diff changeset
449
Ritor1
parents:
diff changeset
450 lpDisplayDevice->StateFlags = DISPLAY_DEVICE_ATTACHED_TO_DESKTOP | DISPLAY_DEVICE_PRIMARY_DEVICE;
Ritor1
parents:
diff changeset
451
Ritor1
parents:
diff changeset
452 return TRUE;
Ritor1
parents:
diff changeset
453 }
Ritor1
parents:
diff changeset
454
Ritor1
parents:
diff changeset
455 #undef xPRIMARY_MONITOR
Ritor1
parents:
diff changeset
456 #undef COMPILE_MULTIMON_STUBS
Ritor1
parents:
diff changeset
457
Ritor1
parents:
diff changeset
458 #else // COMPILE_MULTIMON_STUBS
Ritor1
parents:
diff changeset
459
Ritor1
parents:
diff changeset
460 extern int WINAPI xGetSystemMetrics(int);
Ritor1
parents:
diff changeset
461 extern HMONITOR WINAPI xMonitorFromWindow(HWND, DWORD);
Ritor1
parents:
diff changeset
462 extern HMONITOR WINAPI xMonitorFromRect(LPCRECT, DWORD);
Ritor1
parents:
diff changeset
463 extern HMONITOR WINAPI xMonitorFromPoint(POINT, DWORD);
Ritor1
parents:
diff changeset
464 extern BOOL WINAPI xGetMonitorInfo(HMONITOR, LPMONITORINFO);
Ritor1
parents:
diff changeset
465 extern BOOL WINAPI xEnumDisplayMonitors(HDC, LPCRECT, MONITORENUMPROC, LPARAM);
Ritor1
parents:
diff changeset
466 extern BOOL WINAPI xEnumDisplayDevices(PVOID, DWORD, PDISPLAY_DEVICE, DWORD);
Ritor1
parents:
diff changeset
467
Ritor1
parents:
diff changeset
468 #endif // COMPILE_MULTIMON_STUBS
Ritor1
parents:
diff changeset
469
Ritor1
parents:
diff changeset
470 //
Ritor1
parents:
diff changeset
471 // build defines that replace the regular APIs with our versions
Ritor1
parents:
diff changeset
472 //
Ritor1
parents:
diff changeset
473 #define GetSystemMetrics xGetSystemMetrics
Ritor1
parents:
diff changeset
474 #define MonitorFromWindow xMonitorFromWindow
Ritor1
parents:
diff changeset
475 #define MonitorFromRect xMonitorFromRect
Ritor1
parents:
diff changeset
476 #define MonitorFromPoint xMonitorFromPoint
Ritor1
parents:
diff changeset
477 #define GetMonitorInfo xGetMonitorInfo
Ritor1
parents:
diff changeset
478 #define EnumDisplayMonitors xEnumDisplayMonitors
Ritor1
parents:
diff changeset
479 #define EnumDisplayDevices xEnumDisplayDevices
Ritor1
parents:
diff changeset
480
Ritor1
parents:
diff changeset
481 #ifdef __cplusplus
Ritor1
parents:
diff changeset
482 }
Ritor1
parents:
diff changeset
483 #endif // __cplusplus
Ritor1
parents:
diff changeset
484