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
;
204 if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName
, (PCSZ
)lpszDeviceName
) )
206 SetLastError ( ERROR_OUTOFMEMORY
);
211 * NOTE: We don't need to convert between DEVMODEW and DEVMODEA because
212 * only dmBitsPerPel, dmPelsWidth, dmPelsHeight, dmDisplayFlags and
213 * dmDisplayFrequency fields are set.
215 rc
= NtUserEnumDisplaySettings ( &DeviceName
, iModeNum
, (LPDEVMODEW
)lpDevMode
,
218 RtlFreeUnicodeString ( &DeviceName
);
229 EnumDisplaySettingsA(
230 LPCSTR lpszDeviceName
,
232 LPDEVMODEA lpDevMode
)
234 return EnumDisplaySettingsExA ( lpszDeviceName
, iModeNum
, lpDevMode
, 0 );
243 EnumDisplaySettingsExW(
244 LPCWSTR lpszDeviceName
,
246 LPDEVMODEW lpDevMode
,
250 UNICODE_STRING DeviceName
;
252 RtlInitUnicodeString ( &DeviceName
, lpszDeviceName
);
254 rc
= NtUserEnumDisplaySettings ( &DeviceName
, iModeNum
, lpDevMode
, dwFlags
);
256 RtlFreeUnicodeString ( &DeviceName
);
267 EnumDisplaySettingsW(
268 LPCWSTR lpszDeviceName
,
270 LPDEVMODEW lpDevMode
)
272 return EnumDisplaySettingsExW ( lpszDeviceName
, iModeNum
, lpDevMode
, 0 );
285 if (lpmi
->cbSize
== sizeof (MONITORINFO
))
287 return NtUserGetMonitorInfo(hMonitor
, lpmi
);
289 else if (lpmi
->cbSize
!= sizeof (MONITORINFOEXA
))
291 SetLastError(ERROR_INVALID_PARAMETER
);
296 MONITORINFOEXW miExW
;
299 miExW
.cbSize
= sizeof (MONITORINFOEXW
);
300 if (!NtUserGetMonitorInfo(hMonitor
, (LPMONITORINFO
)&miExW
))
304 memcpy(lpmi
, &miExW
, sizeof (MONITORINFO
));
305 res
= WideCharToMultiByte(CP_THREAD_ACP
, 0, miExW
.szDevice
, -1,
306 ((LPMONITORINFOEXA
)lpmi
)->szDevice
, CCHDEVICENAME
,
310 DPRINT("WideCharToMultiByte() failed!\n");
328 return NtUserGetMonitorInfo(hMonitor
, lpmi
);
341 return NtUserMonitorFromPoint(ptPoint
, dwFlags
);
354 return NtUserMonitorFromRect(lpcRect
, dwFlags
);
367 return NtUserMonitorFromWindow(hWnd
, dwFlags
);
376 ChangeDisplaySettingsExA(
377 LPCSTR lpszDeviceName
,
378 LPDEVMODEA lpDevMode
,
384 UNICODE_STRING DeviceName
;
385 PUNICODE_STRING pDeviceName
= &DeviceName
;
387 LPDEVMODEW pDevModeW
= &DevModeW
;
389 if (lpszDeviceName
!= NULL
)
391 if ( !RtlCreateUnicodeStringFromAsciiz ( pDeviceName
, (PCSZ
)lpszDeviceName
) )
393 SetLastError ( ERROR_OUTOFMEMORY
);
394 return DISP_CHANGE_BADPARAM
; /* FIXME what to return? */
400 if (lpDevMode
!= NULL
)
401 RosRtlDevModeA2W ( pDevModeW
, lpDevMode
);
405 rc
= NtUserChangeDisplaySettings ( pDeviceName
, pDevModeW
, hwnd
, dwflags
, lParam
);
407 if (lpszDeviceName
!= NULL
)
408 RtlFreeUnicodeString ( &DeviceName
);
419 ChangeDisplaySettingsA(
420 LPDEVMODEA lpDevMode
,
423 return ChangeDisplaySettingsExA ( NULL
, lpDevMode
, NULL
, dwflags
, 0 );
432 ChangeDisplaySettingsExW(
433 LPCWSTR lpszDeviceName
,
434 LPDEVMODEW lpDevMode
,
440 UNICODE_STRING DeviceName
;
441 PUNICODE_STRING pDeviceName
= &DeviceName
;
443 if (lpszDeviceName
!= NULL
)
444 RtlInitUnicodeString ( pDeviceName
, lpszDeviceName
);
448 rc
= NtUserChangeDisplaySettings ( pDeviceName
, lpDevMode
, hwnd
, dwflags
, lParam
);
450 if (lpszDeviceName
!= NULL
)
451 RtlFreeUnicodeString ( pDeviceName
);
462 ChangeDisplaySettingsW(
463 LPDEVMODEW lpDevMode
,
466 return ChangeDisplaySettingsExW ( NULL
, lpDevMode
, NULL
, dwflags
, 0 );