2004-08-15 Casper S. Hornstrup <chorns@users.sourceforge.net>
[reactos.git] / reactos / lib / user32 / misc / display.c
1 /*
2 * ReactOS kernel
3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19 /* $Id: display.c,v 1.12 2004/08/15 21:36:28 chorns Exp $
20 *
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/misc/dde.c
23 * PURPOSE: DDE
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
25 * UPDATE HISTORY:
26 * 09-05-2001 CSH Created
27 */
28
29 /* INCLUDES ******************************************************************/
30
31 #include "user32.h"
32 #include <rosrtl/devmode.h>
33 #include <win32k/ntuser.h>
34 #define NDEBUG
35 #include <debug.h>
36
37 /* FUNCTIONS *****************************************************************/
38
39 /*
40 * @implemented
41 */
42 BOOL STDCALL
43 EnumDisplayDevicesA(
44 LPCSTR lpDevice,
45 DWORD iDevNum,
46 PDISPLAY_DEVICEA lpDisplayDevice,
47 DWORD dwFlags)
48 {
49 /* FIXME: This implementation doesn't convert the lpDisplayDevice structure! */
50 #if 0
51 BOOL rc;
52 UNICODE_STRING Device;
53 if ( !RtlCreateUnicodeStringFromAsciiz ( &Device, (PCSZ)lpDevice ) )
54 {
55 SetLastError ( ERROR_OUTOFMEMORY );
56 return FALSE;
57 }
58
59 rc = NtUserEnumDisplayDevices (
60 &Device,
61 iDevNum,
62 lpDisplayDevice,
63 dwFlags );
64
65 RtlFreeUnicodeString ( &Device );
66
67 return rc;
68 #else
69 return 0;
70 #endif
71 }
72
73
74 /*
75 * @implemented
76 */
77 BOOL
78 STDCALL
79 EnumDisplayDevicesW(
80 LPCWSTR lpDevice,
81 DWORD iDevNum,
82 PDISPLAY_DEVICE lpDisplayDevice,
83 DWORD dwFlags)
84 {
85 UNICODE_STRING Device;
86 BOOL rc;
87
88 RtlInitUnicodeString ( &Device, lpDevice );
89
90 rc = NtUserEnumDisplayDevices (
91 &Device,
92 iDevNum,
93 lpDisplayDevice,
94 dwFlags );
95
96 RtlFreeUnicodeString ( &Device );
97
98 return rc;
99 }
100
101
102 /*
103 * @implemented
104 */
105 BOOL
106 STDCALL
107 EnumDisplayMonitors(
108 HDC hdc,
109 LPCRECT lprcClip,
110 MONITORENUMPROC lpfnEnum,
111 LPARAM dwData)
112 {
113 return NtUserEnumDisplayMonitors ( hdc, lprcClip, lpfnEnum, dwData );
114 }
115
116
117 /*
118 * @implemented
119 */
120 BOOL
121 STDCALL
122 EnumDisplaySettingsExA(
123 LPCSTR lpszDeviceName,
124 DWORD iModeNum,
125 LPDEVMODEA lpDevMode,
126 DWORD dwFlags)
127 {
128 BOOL rc;
129 UNICODE_STRING DeviceName;
130 DEVMODEW DevModeW;
131
132 if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName, (PCSZ)lpszDeviceName ) )
133 {
134 SetLastError ( ERROR_OUTOFMEMORY );
135 return FALSE;
136 }
137
138 RosRtlDevModeA2W ( &DevModeW, lpDevMode );
139
140 rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, &DevModeW, dwFlags );
141
142 RtlFreeUnicodeString ( &DeviceName );
143 RosRtlDevModeW2A ( lpDevMode, &DevModeW );
144
145 return rc;
146 }
147
148
149 /*
150 * @implemented
151 */
152 BOOL
153 STDCALL
154 EnumDisplaySettingsA(
155 LPCSTR lpszDeviceName,
156 DWORD iModeNum,
157 LPDEVMODEA lpDevMode)
158 {
159 return EnumDisplaySettingsExA ( lpszDeviceName, iModeNum, lpDevMode, 0 );
160 }
161
162
163 /*
164 * @implemented
165 */
166 BOOL
167 STDCALL
168 EnumDisplaySettingsExW(
169 LPCWSTR lpszDeviceName,
170 DWORD iModeNum,
171 LPDEVMODEW lpDevMode,
172 DWORD dwFlags)
173 {
174 BOOL rc;
175 UNICODE_STRING DeviceName;
176
177 RtlInitUnicodeString ( &DeviceName, lpszDeviceName );
178
179 rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, lpDevMode, dwFlags );
180
181 RtlFreeUnicodeString ( &DeviceName );
182
183 return rc;
184 }
185
186
187 /*
188 * @implemented
189 */
190 BOOL
191 STDCALL
192 EnumDisplaySettingsW(
193 LPCWSTR lpszDeviceName,
194 DWORD iModeNum,
195 LPDEVMODEW lpDevMode)
196 {
197 return EnumDisplaySettingsExW ( lpszDeviceName, iModeNum, lpDevMode, 0 );
198 }
199
200
201 /*
202 * @unimplemented
203 */
204 BOOL
205 STDCALL
206 GetMonitorInfoA(
207 HMONITOR hMonitor,
208 LPMONITORINFO lpmi)
209 {
210 UNIMPLEMENTED;
211 return FALSE;
212 }
213
214
215 /*
216 * @unimplemented
217 */
218 BOOL
219 STDCALL
220 GetMonitorInfoW(
221 HMONITOR hMonitor,
222 LPMONITORINFO lpmi)
223 {
224 UNIMPLEMENTED;
225 return FALSE;
226 }
227
228
229 /*
230 * @implemented
231 */
232 LONG
233 STDCALL
234 ChangeDisplaySettingsExA(
235 LPCSTR lpszDeviceName,
236 LPDEVMODEA lpDevMode,
237 HWND hwnd,
238 DWORD dwflags,
239 LPVOID lParam)
240 {
241 LONG rc;
242 UNICODE_STRING DeviceName;
243 PUNICODE_STRING pDeviceName = &DeviceName;
244 DEVMODEW DevModeW;
245 LPDEVMODEW pDevModeW = &DevModeW;
246
247 if (lpszDeviceName != NULL)
248 {
249 if ( !RtlCreateUnicodeStringFromAsciiz ( pDeviceName, (PCSZ)lpszDeviceName ) )
250 {
251 SetLastError ( ERROR_OUTOFMEMORY );
252 return DISP_CHANGE_BADPARAM; /* FIXME what to return? */
253 }
254 }
255 else
256 pDeviceName = NULL;
257
258 if (lpDevMode != NULL)
259 RosRtlDevModeA2W ( pDevModeW, lpDevMode );
260 else
261 pDevModeW = NULL;
262
263 rc = NtUserChangeDisplaySettings ( pDeviceName, pDevModeW, hwnd, dwflags, lParam );
264
265 if (lpszDeviceName != NULL)
266 RtlFreeUnicodeString ( &DeviceName );
267
268 return rc;
269 }
270
271
272 /*
273 * @implemented
274 */
275 LONG
276 STDCALL
277 ChangeDisplaySettingsA(
278 LPDEVMODEA lpDevMode,
279 DWORD dwflags)
280 {
281 return ChangeDisplaySettingsExA ( NULL, lpDevMode, NULL, dwflags, 0 );
282 }
283
284
285 /*
286 * @implemented
287 */
288 LONG
289 STDCALL
290 ChangeDisplaySettingsExW(
291 LPCWSTR lpszDeviceName,
292 LPDEVMODEW lpDevMode,
293 HWND hwnd,
294 DWORD dwflags,
295 LPVOID lParam)
296 {
297 LONG rc;
298 UNICODE_STRING DeviceName;
299 PUNICODE_STRING pDeviceName = &DeviceName;
300
301 if (lpszDeviceName != NULL)
302 RtlInitUnicodeString ( pDeviceName, lpszDeviceName );
303 else
304 pDeviceName = NULL;
305
306 rc = NtUserChangeDisplaySettings ( pDeviceName, lpDevMode, hwnd, dwflags, lParam );
307
308 if (lpszDeviceName != NULL)
309 RtlFreeUnicodeString ( pDeviceName );
310
311 return rc;
312 }
313
314
315 /*
316 * @implemented
317 */
318 LONG
319 STDCALL
320 ChangeDisplaySettingsW(
321 LPDEVMODEW lpDevMode,
322 DWORD dwflags)
323 {
324 return ChangeDisplaySettingsExW ( NULL, lpDevMode, NULL, dwflags, 0 );
325 }