annotate lib/legacy_dx/multimon.h @ 201:11a199790ce0

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