3 * Copyright (C) 1998, 1999, 2000, 2001 ReactOS Team
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.
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.
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.
21 * PROJECT: ReactOS user32.dll
22 * FILE: lib/user32/misc/dde.c
24 * PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
26 * 09-05-2001 CSH Created
29 /* INCLUDES ******************************************************************/
32 #include <rosrtl/devmode.h>
33 #include <win32k/ntuser.h>
37 /* FUNCTIONS *****************************************************************/
46 PDISPLAY_DEVICEA lpDisplayDevice
,
50 UNICODE_STRING Device
;
51 DISPLAY_DEVICEW DisplayDeviceW
;
53 if ( !RtlCreateUnicodeStringFromAsciiz ( &Device
, (PCSZ
)lpDevice
) )
55 SetLastError ( ERROR_OUTOFMEMORY
);
59 DisplayDeviceW
.cb
= lpDisplayDevice
->cb
;
60 rc
= NtUserEnumDisplayDevices (
66 /* Copy result from DisplayDeviceW to lpDisplayDevice */
67 lpDisplayDevice
->StateFlags
= DisplayDeviceW
.StateFlags
;
68 WideCharToMultiByte(CP_ACP
,0,
69 DisplayDeviceW
.DeviceName
,wcslen(DisplayDeviceW
.DeviceName
),
70 lpDisplayDevice
->DeviceName
,sizeof(lpDisplayDevice
->DeviceName
) / sizeof(lpDisplayDevice
->DeviceName
[0]),
72 WideCharToMultiByte(CP_ACP
,0,
73 DisplayDeviceW
.DeviceString
,wcslen(DisplayDeviceW
.DeviceString
),
74 lpDisplayDevice
->DeviceString
,sizeof(lpDisplayDevice
->DeviceString
) / sizeof(lpDisplayDevice
->DeviceString
[0]),
76 WideCharToMultiByte(CP_ACP
,0,
77 DisplayDeviceW
.DeviceID
,wcslen(DisplayDeviceW
.DeviceID
),
78 lpDisplayDevice
->DeviceID
,sizeof(lpDisplayDevice
->DeviceID
) / sizeof(lpDisplayDevice
->DeviceID
[0]),
80 WideCharToMultiByte(CP_ACP
,0,
81 DisplayDeviceW
.DeviceKey
,wcslen(DisplayDeviceW
.DeviceKey
),
82 lpDisplayDevice
->DeviceKey
,sizeof(lpDisplayDevice
->DeviceKey
) / sizeof(lpDisplayDevice
->DeviceKey
[0]),
85 RtlFreeUnicodeString ( &Device
);
99 PDISPLAY_DEVICE lpDisplayDevice
,
102 UNICODE_STRING Device
;
105 RtlInitUnicodeString ( &Device
, lpDevice
);
107 rc
= NtUserEnumDisplayDevices (
113 RtlFreeUnicodeString ( &Device
);
127 MONITORENUMPROC lpfnEnum
,
131 HMONITOR
*hMonitorList
;
135 /* get list of monitors/rects */
136 iCount
= NtUserEnumDisplayMonitors(hdc
, lprcClip
, NULL
, NULL
, 0);
139 /* FIXME: SetLastError() */
147 hHeap
= GetProcessHeap();
148 hMonitorList
= HeapAlloc(hHeap
, 0, sizeof (HMONITOR
) * iCount
);
149 if (hMonitorList
== NULL
)
151 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
154 pRectList
= HeapAlloc(hHeap
, 0, sizeof (RECT
) * iCount
);
155 if (pRectList
== NULL
)
157 HeapFree(hHeap
, 0, hMonitorList
);
158 SetLastError(ERROR_NOT_ENOUGH_MEMORY
);
162 iCount
= NtUserEnumDisplayMonitors(hdc
, lprcClip
, hMonitorList
, pRectList
, iCount
);
165 /* FIXME: SetLastError() */
170 for (i
= 0; i
< iCount
; i
++)
172 HMONITOR hMonitor
= hMonitorList
[i
];
173 LPRECT pMonitorRect
= pRectList
+ i
;
174 HDC hMonitorDC
= NULL
;
178 /* make monitor DC */
182 if (!lpfnEnum(hMonitor
, hMonitorDC
, pMonitorRect
, dwData
))
195 EnumDisplaySettingsExA(
196 LPCSTR lpszDeviceName
,
198 LPDEVMODEA lpDevMode
,
202 UNICODE_STRING DeviceName
;
203 LPDEVMODEW lpDevModeW
;
205 lpDevModeW
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
,
206 sizeof(DEVMODEW
) + lpDevMode
->dmDriverExtra
);
207 if ( lpDevModeW
== NULL
)
209 SetLastError ( ERROR_OUTOFMEMORY
);
213 if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName
, (PCSZ
)lpszDeviceName
) )
215 SetLastError ( ERROR_OUTOFMEMORY
);
219 lpDevModeW
->dmSize
= sizeof(DEVMODEW
);
220 lpDevModeW
->dmDriverExtra
= 0;
222 rc
= NtUserEnumDisplaySettings ( &DeviceName
, iModeNum
, lpDevModeW
,
225 RosRtlDevModeW2A ( lpDevMode
, lpDevModeW
);
227 RtlFreeUnicodeString ( &DeviceName
);
228 HeapFree ( GetProcessHeap(), 0, lpDevModeW
);
239 EnumDisplaySettingsA(
240 LPCSTR lpszDeviceName
,
242 LPDEVMODEA lpDevMode
)
244 return EnumDisplaySettingsExA ( lpszDeviceName
, iModeNum
, lpDevMode
, 0 );
253 EnumDisplaySettingsExW(
254 LPCWSTR lpszDeviceName
,
256 LPDEVMODEW lpDevMode
,
260 UNICODE_STRING DeviceName
;
262 RtlInitUnicodeString ( &DeviceName
, lpszDeviceName
);
264 rc
= NtUserEnumDisplaySettings ( &DeviceName
, iModeNum
, lpDevMode
, dwFlags
);
266 RtlFreeUnicodeString ( &DeviceName
);
277 EnumDisplaySettingsW(
278 LPCWSTR lpszDeviceName
,
280 LPDEVMODEW lpDevMode
)
282 return EnumDisplaySettingsExW ( lpszDeviceName
, iModeNum
, lpDevMode
, 0 );
295 if (lpmi
->cbSize
== sizeof (MONITORINFO
))
297 return NtUserGetMonitorInfo(hMonitor
, lpmi
);
299 else if (lpmi
->cbSize
!= sizeof (MONITORINFOEXA
))
301 SetLastError(ERROR_INVALID_PARAMETER
);
306 MONITORINFOEXW miExW
;
309 miExW
.cbSize
= sizeof (MONITORINFOEXW
);
310 if (!NtUserGetMonitorInfo(hMonitor
, (LPMONITORINFO
)&miExW
))
314 memcpy(lpmi
, &miExW
, sizeof (MONITORINFO
));
315 res
= WideCharToMultiByte(CP_THREAD_ACP
, 0, miExW
.szDevice
, -1,
316 ((LPMONITORINFOEXA
)lpmi
)->szDevice
, CCHDEVICENAME
,
320 DPRINT("WideCharToMultiByte() failed!\n");
338 return NtUserGetMonitorInfo(hMonitor
, lpmi
);
351 return NtUserMonitorFromPoint(ptPoint
, dwFlags
);
364 return NtUserMonitorFromRect(lpcRect
, dwFlags
);
377 return NtUserMonitorFromWindow(hWnd
, dwFlags
);
386 ChangeDisplaySettingsExA(
387 LPCSTR lpszDeviceName
,
388 LPDEVMODEA lpDevMode
,
394 UNICODE_STRING DeviceName
;
395 PUNICODE_STRING pDeviceName
= &DeviceName
;
397 LPDEVMODEW pDevModeW
= &DevModeW
;
399 if (lpszDeviceName
!= NULL
)
401 if ( !RtlCreateUnicodeStringFromAsciiz ( pDeviceName
, (PCSZ
)lpszDeviceName
) )
403 SetLastError ( ERROR_OUTOFMEMORY
);
404 return DISP_CHANGE_BADPARAM
; /* FIXME what to return? */
410 if (lpDevMode
!= NULL
)
411 RosRtlDevModeA2W ( pDevModeW
, lpDevMode
);
415 rc
= NtUserChangeDisplaySettings ( pDeviceName
, pDevModeW
, hwnd
, dwflags
, lParam
);
417 if (lpszDeviceName
!= NULL
)
418 RtlFreeUnicodeString ( &DeviceName
);
429 ChangeDisplaySettingsA(
430 LPDEVMODEA lpDevMode
,
433 return ChangeDisplaySettingsExA ( NULL
, lpDevMode
, NULL
, dwflags
, 0 );
442 ChangeDisplaySettingsExW(
443 LPCWSTR lpszDeviceName
,
444 LPDEVMODEW lpDevMode
,
450 UNICODE_STRING DeviceName
;
451 PUNICODE_STRING pDeviceName
= &DeviceName
;
453 if (lpszDeviceName
!= NULL
)
454 RtlInitUnicodeString ( pDeviceName
, lpszDeviceName
);
458 rc
= NtUserChangeDisplaySettings ( pDeviceName
, lpDevMode
, hwnd
, dwflags
, lParam
);
460 if (lpszDeviceName
!= NULL
)
461 RtlFreeUnicodeString ( pDeviceName
);
472 ChangeDisplaySettingsW(
473 LPDEVMODEW lpDevMode
,
476 return ChangeDisplaySettingsExW ( NULL
, lpDevMode
, NULL
, dwflags
, 0 );