branch update for HEAD-2003091401
[reactos.git] / lib / user32 / misc / display.c
index 966a49c..62e7825 100644 (file)
 #include <windows.h>
 #include <user32.h>
 #include <debug.h>
+#include <rosrtl/devmode.h>
 
 /* FUNCTIONS *****************************************************************/
 
+/*
+ * @implemented
+ */
 WINBOOL STDCALL
 EnumDisplayDevicesA(
   LPCSTR lpDevice,
@@ -41,9 +45,29 @@ EnumDisplayDevicesA(
   PDISPLAY_DEVICE lpDisplayDevice,
   DWORD dwFlags)
 {
-  return FALSE;
+  WINBOOL rc;
+  UNICODE_STRING Device;
+  if ( !RtlCreateUnicodeStringFromAsciiz ( &Device, (PCSZ)lpDevice ) )
+    {
+      SetLastError ( ERROR_OUTOFMEMORY );
+      return FALSE;
+    }
+
+  rc = NtUserEnumDisplayDevices (
+    &Device,
+    iDevNum,
+    lpDisplayDevice,
+    dwFlags );
+
+  RtlFreeUnicodeString ( &Device );
+
+  return rc;
 }
 
+
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 EnumDisplayDevicesW(
@@ -52,52 +76,110 @@ EnumDisplayDevicesW(
   PDISPLAY_DEVICE lpDisplayDevice,
   DWORD dwFlags)
 {
-  return FALSE;
+  UNICODE_STRING Device;
+  WINBOOL rc;
+
+  RtlInitUnicodeString ( &Device, lpDevice );
+
+  rc = NtUserEnumDisplayDevices (
+    &Device,
+    iDevNum,
+    lpDisplayDevice,
+    dwFlags );
+
+  RtlFreeUnicodeString ( &Device );
+
+  return rc;
 }
 
+
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 EnumDisplayMonitors(
   HDC hdc,
-  LPRECT lprcClip,
+  LPCRECT lprcClip,
   MONITORENUMPROC lpfnEnum,
   LPARAM dwData)
 {
-  return FALSE;
+  return NtUserEnumDisplayMonitors ( hdc, lprcClip, lpfnEnum, dwData );
 }
 
+
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
-EnumDisplaySettingsA(
+EnumDisplaySettingsExA(
   LPCSTR lpszDeviceName,
   DWORD iModeNum,
-  LPDEVMODEA lpDevMode)
+  LPDEVMODEA lpDevMode,
+  DWORD dwFlags)
 {
-  return FALSE;
+  WINBOOL rc;
+  UNICODE_STRING DeviceName;
+  DEVMODEW DevModeW;
+
+  if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName, (PCSZ)lpszDeviceName ) )
+    {
+      SetLastError ( ERROR_OUTOFMEMORY );
+      return FALSE;
+    }
+
+  RosRtlDevModeA2W ( &DevModeW, lpDevMode );
+
+  rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, &DevModeW, dwFlags );
+
+  RtlFreeUnicodeString ( &DeviceName );
+
+  return rc;
 }
 
+
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
-EnumDisplaySettingsExA(
+EnumDisplaySettingsA(
   LPCSTR lpszDeviceName,
   DWORD iModeNum,
-  LPDEVMODEW lpDevMode,
-  DWORD dwFlags)
+  LPDEVMODEA lpDevMode)
 {
-  return FALSE;
+       return EnumDisplaySettingsExA ( lpszDeviceName, iModeNum, lpDevMode, 0 );
 }
 
+
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 EnumDisplaySettingsExW(
   LPCWSTR lpszDeviceName,
   DWORD iModeNum,
-  LPDEVMODEA lpDevMode,
+  LPDEVMODEW lpDevMode,
   DWORD dwFlags)
 {
-  return FALSE;
+  WINBOOL rc;
+  UNICODE_STRING DeviceName;
+
+  RtlInitUnicodeString ( &DeviceName, lpszDeviceName );
+
+  rc = NtUserEnumDisplaySettings ( &DeviceName, iModeNum, lpDevMode, dwFlags );
+
+  RtlFreeUnicodeString ( &DeviceName );
+
+  return rc;
 }
 
+
+/*
+ * @implemented
+ */
 WINBOOL
 STDCALL
 EnumDisplaySettingsW(
@@ -105,34 +187,41 @@ EnumDisplaySettingsW(
   DWORD iModeNum,
   LPDEVMODEW lpDevMode)
 {
-  return FALSE;
+       return EnumDisplaySettingsExW ( lpszDeviceName, iModeNum, lpDevMode, 0 );
 }
+
+
+/*
+ * @unimplemented
+ */
 WINBOOL
 STDCALL
 GetMonitorInfoA(
   HMONITOR hMonitor,
   LPMONITORINFO lpmi)
 {
+  UNIMPLEMENTED;
   return FALSE;
 }
 
+
+/*
+ * @unimplemented
+ */
 WINBOOL
 STDCALL
 GetMonitorInfoW(
   HMONITOR hMonitor,
   LPMONITORINFO lpmi)
 {
+  UNIMPLEMENTED;
   return FALSE;
 }
-LONG
-STDCALL
-ChangeDisplaySettingsA(
-  LPDEVMODEA lpDevMode,
-  DWORD dwflags)
-{
-  return 0;
-}
 
+
+/*
+ * @implemented
+ */
 LONG
 STDCALL
 ChangeDisplaySettingsExA(
@@ -142,9 +231,42 @@ ChangeDisplaySettingsExA(
   DWORD dwflags,
   LPVOID lParam)
 {
-  return 0;
+  LONG rc;
+  UNICODE_STRING DeviceName;
+  DEVMODEW DevModeW;
+
+  if ( !RtlCreateUnicodeStringFromAsciiz ( &DeviceName, (PCSZ)lpszDeviceName ) )
+    {
+      SetLastError ( ERROR_OUTOFMEMORY );
+      return DISP_CHANGE_BADPARAM; /* FIXME what to return? */
+    }
+
+  RosRtlDevModeA2W ( &DevModeW, lpDevMode );
+
+  rc = NtUserChangeDisplaySettings ( &DeviceName, &DevModeW, hwnd, dwflags, lParam );
+
+  RtlFreeUnicodeString ( &DeviceName );
+
+  return rc;
+}
+
+
+/*
+ * @implemented
+ */
+LONG
+STDCALL
+ChangeDisplaySettingsA(
+  LPDEVMODEA lpDevMode,
+  DWORD dwflags)
+{
+  return ChangeDisplaySettingsExA ( NULL, lpDevMode, NULL, dwflags, 0 );
 }
 
+
+/*
+ * @implemented
+ */
 LONG
 STDCALL
 ChangeDisplaySettingsExW(
@@ -154,14 +276,27 @@ ChangeDisplaySettingsExW(
   DWORD dwflags,
   LPVOID lParam)
 {
-  return 0;
+  LONG rc;
+  UNICODE_STRING DeviceName;
+
+  RtlInitUnicodeString ( &DeviceName, lpszDeviceName );
+
+  rc = NtUserChangeDisplaySettings ( &DeviceName, lpDevMode, hwnd, dwflags, lParam );
+
+  RtlFreeUnicodeString ( &DeviceName );
+
+  return rc;
 }
 
+
+/*
+ * @implemented
+ */
 LONG
 STDCALL
 ChangeDisplaySettingsW(
   LPDEVMODEW lpDevMode,
   DWORD dwflags)
 {
-  return 0;
+  return ChangeDisplaySettingsExW ( NULL, lpDevMode, NULL, dwflags, 0 );
 }