2002-06-13 20:36:40 +00:00
|
|
|
/*
|
|
|
|
* PROJECT: ReactOS user32.dll
|
2015-11-01 09:41:29 +00:00
|
|
|
* FILE: win32ss/user/user32/misc/display.c
|
2002-06-13 20:36:40 +00:00
|
|
|
* PURPOSE: DDE
|
|
|
|
* PROGRAMMER: Casper S. Hornstrup (chorns@users.sourceforge.net)
|
|
|
|
*/
|
|
|
|
|
|
|
|
/* INCLUDES ******************************************************************/
|
|
|
|
|
2005-06-19 18:06:53 +00:00
|
|
|
#include <user32.h>
|
2006-06-26 13:16:43 +00:00
|
|
|
|
|
|
|
#include <wine/debug.h>
|
2007-07-26 15:13:36 +00:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(user32);
|
2005-07-01 01:54:55 +00:00
|
|
|
|
|
|
|
#define SIZEOF_DEVMODEA_300 124
|
|
|
|
#define SIZEOF_DEVMODEA_400 148
|
|
|
|
#define SIZEOF_DEVMODEA_500 156
|
|
|
|
#define SIZEOF_DEVMODEW_300 188
|
|
|
|
#define SIZEOF_DEVMODEW_400 212
|
|
|
|
#define SIZEOF_DEVMODEW_500 220
|
2002-06-13 20:36:40 +00:00
|
|
|
|
|
|
|
/* FUNCTIONS *****************************************************************/
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2008-11-30 11:42:05 +00:00
|
|
|
BOOL WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
EnumDisplayDevicesA(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPCSTR lpDevice,
|
|
|
|
DWORD iDevNum,
|
|
|
|
PDISPLAY_DEVICEA lpDisplayDevice,
|
|
|
|
DWORD dwFlags)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
BOOL rc;
|
|
|
|
UNICODE_STRING Device;
|
|
|
|
DISPLAY_DEVICEW DisplayDeviceW;
|
2005-05-09 01:42:07 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
if (!RtlCreateUnicodeStringFromAsciiz(&Device, (PCSZ)lpDevice))
|
2003-07-19 01:35:27 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
return FALSE;
|
2003-07-19 01:35:27 +00:00
|
|
|
}
|
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
RtlZeroMemory(&DisplayDeviceW, sizeof(DISPLAY_DEVICEW));
|
|
|
|
DisplayDeviceW.cb = sizeof(DISPLAY_DEVICEW);
|
|
|
|
rc = NtUserEnumDisplayDevices(&Device,
|
|
|
|
iDevNum,
|
|
|
|
&DisplayDeviceW,
|
|
|
|
dwFlags);
|
|
|
|
if (rc)
|
2006-06-04 13:36:39 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
/* Copy result from DisplayDeviceW to lpDisplayDevice. Buffers have the same size so result is always NULL terminated. */
|
|
|
|
lpDisplayDevice->StateFlags = DisplayDeviceW.StateFlags;
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceName, -1,
|
|
|
|
lpDisplayDevice->DeviceName,
|
|
|
|
sizeof(lpDisplayDevice->DeviceName) / sizeof(lpDisplayDevice->DeviceName[0]),
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceString, -1,
|
|
|
|
lpDisplayDevice->DeviceString,
|
|
|
|
sizeof(lpDisplayDevice->DeviceString) / sizeof(lpDisplayDevice->DeviceString[0]),
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceID, -1,
|
|
|
|
lpDisplayDevice->DeviceID,
|
|
|
|
sizeof(lpDisplayDevice->DeviceID) / sizeof(lpDisplayDevice->DeviceID[0]),
|
|
|
|
NULL, NULL);
|
|
|
|
WideCharToMultiByte(CP_ACP, 0, DisplayDeviceW.DeviceKey, -1,
|
|
|
|
lpDisplayDevice->DeviceKey,
|
|
|
|
sizeof(lpDisplayDevice->DeviceKey) / sizeof(lpDisplayDevice->DeviceKey[0]),
|
|
|
|
NULL, NULL);
|
2006-06-04 13:36:39 +00:00
|
|
|
}
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
RtlFreeUnicodeString(&Device);
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
return rc;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
EnumDisplayDevicesW(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPCWSTR lpDevice,
|
|
|
|
DWORD iDevNum,
|
2011-05-30 21:34:10 +00:00
|
|
|
PDISPLAY_DEVICEW lpDisplayDevice,
|
2011-03-26 01:20:11 +00:00
|
|
|
DWORD dwFlags)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
UNICODE_STRING Device;
|
|
|
|
BOOL rc;
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
RtlInitUnicodeString(&Device, lpDevice);
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
rc = NtUserEnumDisplayDevices(
|
|
|
|
&Device,
|
|
|
|
iDevNum,
|
|
|
|
lpDisplayDevice,
|
|
|
|
dwFlags);
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
return rc;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
EnumDisplayMonitors(
|
2011-03-26 01:20:11 +00:00
|
|
|
HDC hdc,
|
|
|
|
LPCRECT lprcClip,
|
|
|
|
MONITORENUMPROC lpfnEnum,
|
|
|
|
LPARAM dwData)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
INT iCount, i;
|
|
|
|
HMONITOR *hMonitorList;
|
|
|
|
LPRECT pRectList;
|
|
|
|
HANDLE hHeap;
|
2011-03-27 01:12:25 +00:00
|
|
|
BOOL ret = FALSE;
|
2011-03-26 01:20:11 +00:00
|
|
|
|
|
|
|
/* get list of monitors/rects */
|
|
|
|
iCount = NtUserEnumDisplayMonitors(hdc, lprcClip, NULL, NULL, 0);
|
|
|
|
if (iCount < 0)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
/* FIXME: SetLastError() */
|
|
|
|
return FALSE;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
2011-03-26 01:20:11 +00:00
|
|
|
if (iCount == 0)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
return TRUE;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
hHeap = GetProcessHeap();
|
|
|
|
hMonitorList = HeapAlloc(hHeap, 0, sizeof (HMONITOR) * iCount);
|
|
|
|
if (hMonitorList == NULL)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
|
|
|
return FALSE;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
2011-03-26 01:20:11 +00:00
|
|
|
pRectList = HeapAlloc(hHeap, 0, sizeof (RECT) * iCount);
|
|
|
|
if (pRectList == NULL)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
SetLastError(ERROR_NOT_ENOUGH_MEMORY);
|
2011-03-27 01:12:25 +00:00
|
|
|
goto cleanup;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
iCount = NtUserEnumDisplayMonitors(hdc, lprcClip, hMonitorList, pRectList, iCount);
|
|
|
|
if (iCount <= 0)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
/* FIXME: SetLastError() */
|
2011-03-27 01:12:25 +00:00
|
|
|
goto cleanup;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
/* enumerate list */
|
|
|
|
for (i = 0; i < iCount; i++)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
HMONITOR hMonitor = hMonitorList[i];
|
|
|
|
LPRECT pMonitorRect = pRectList + i;
|
|
|
|
HDC hMonitorDC = NULL;
|
2004-11-16 16:29:21 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
if (hdc != NULL)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
/* make monitor DC */
|
|
|
|
hMonitorDC = hdc;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
if (!lpfnEnum(hMonitor, hMonitorDC, pMonitorRect, dwData))
|
2011-03-27 01:12:25 +00:00
|
|
|
goto cleanup; /* return FALSE */
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
2011-03-27 01:12:25 +00:00
|
|
|
|
|
|
|
ret = TRUE;
|
|
|
|
|
|
|
|
cleanup:
|
|
|
|
if(hMonitorList)
|
|
|
|
HeapFree(hHeap, 0, hMonitorList);
|
|
|
|
if(pRectList)
|
|
|
|
HeapFree(hHeap, 0, pRectList);
|
|
|
|
return ret;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2003-07-19 01:35:27 +00:00
|
|
|
EnumDisplaySettingsExA(
|
2008-05-11 23:51:55 +00:00
|
|
|
LPCSTR lpszDeviceName,
|
|
|
|
DWORD iModeNum,
|
|
|
|
LPDEVMODEA lpDevMode,
|
|
|
|
DWORD dwFlags)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2008-05-11 23:51:55 +00:00
|
|
|
NTSTATUS Status;
|
2016-09-11 20:11:35 +00:00
|
|
|
UNICODE_STRING usDeviceName;
|
|
|
|
PUNICODE_STRING pusDeviceName = NULL;
|
|
|
|
LPDEVMODEW lpExtendedDevMode;
|
|
|
|
BOOL Result = FALSE;
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2008-05-11 23:51:55 +00:00
|
|
|
if (lpszDeviceName)
|
2003-07-19 01:35:27 +00:00
|
|
|
{
|
2008-05-11 23:51:55 +00:00
|
|
|
if (!RtlCreateUnicodeStringFromAsciiz(&usDeviceName, (PCSZ)lpszDeviceName))
|
|
|
|
{
|
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
pusDeviceName = &usDeviceName;
|
2003-07-19 01:35:27 +00:00
|
|
|
}
|
|
|
|
|
2016-09-11 20:11:35 +00:00
|
|
|
/* Allocate memory for DEVMODEW and extra data */
|
|
|
|
lpExtendedDevMode = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(DEVMODEW) + lpDevMode->dmDriverExtra);
|
|
|
|
if (!lpExtendedDevMode)
|
2005-07-01 01:54:55 +00:00
|
|
|
{
|
2016-09-11 20:11:35 +00:00
|
|
|
if (pusDeviceName)
|
|
|
|
RtlFreeUnicodeString(&usDeviceName);
|
2005-05-27 14:22:06 +00:00
|
|
|
|
2008-05-11 23:51:55 +00:00
|
|
|
return FALSE;
|
|
|
|
}
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2016-09-11 20:11:35 +00:00
|
|
|
/* Initialize structure fields */
|
|
|
|
lpExtendedDevMode->dmSize = sizeof(DEVMODEW);
|
|
|
|
lpExtendedDevMode->dmDriverExtra = lpDevMode->dmDriverExtra;
|
|
|
|
|
|
|
|
Status = NtUserEnumDisplaySettings(pusDeviceName, iModeNum, lpExtendedDevMode, dwFlags);
|
|
|
|
|
|
|
|
if (pusDeviceName)
|
|
|
|
RtlFreeUnicodeString(&usDeviceName);
|
|
|
|
|
|
|
|
if (NT_SUCCESS(Status))
|
2008-05-11 23:51:55 +00:00
|
|
|
{
|
2016-09-11 20:11:35 +00:00
|
|
|
/* Store old structure size */
|
|
|
|
WORD OldSize = lpDevMode->dmSize;
|
|
|
|
|
|
|
|
#define COPYS(f,len) WideCharToMultiByte(CP_THREAD_ACP, 0, lpExtendedDevMode->f, len, (LPSTR)lpDevMode->f, len, NULL, NULL)
|
|
|
|
#define COPYN(f) lpDevMode->f = lpExtendedDevMode->f
|
|
|
|
|
|
|
|
COPYS(dmDeviceName, CCHDEVICENAME);
|
|
|
|
COPYN(dmSpecVersion);
|
|
|
|
COPYN(dmDriverVersion);
|
|
|
|
COPYN(dmFields);
|
|
|
|
COPYN(dmPosition.x);
|
|
|
|
COPYN(dmPosition.y);
|
|
|
|
COPYN(dmScale);
|
|
|
|
COPYN(dmCopies);
|
|
|
|
COPYN(dmDefaultSource);
|
|
|
|
COPYN(dmPrintQuality);
|
|
|
|
COPYN(dmColor);
|
|
|
|
COPYN(dmDuplex);
|
|
|
|
COPYN(dmYResolution);
|
|
|
|
COPYN(dmTTOption);
|
|
|
|
COPYN(dmCollate);
|
|
|
|
COPYS(dmFormName,CCHFORMNAME);
|
|
|
|
COPYN(dmLogPixels);
|
|
|
|
COPYN(dmBitsPerPel);
|
|
|
|
COPYN(dmPelsWidth);
|
|
|
|
COPYN(dmPelsHeight);
|
|
|
|
COPYN(dmDisplayFlags); // aka dmNup
|
|
|
|
COPYN(dmDisplayFrequency);
|
|
|
|
|
|
|
|
/* we're done with 0x300 fields */
|
|
|
|
if (OldSize > SIZEOF_DEVMODEA_300)
|
|
|
|
{
|
|
|
|
COPYN(dmICMMethod);
|
|
|
|
COPYN(dmICMIntent);
|
|
|
|
COPYN(dmMediaType);
|
|
|
|
COPYN(dmDitherType);
|
|
|
|
COPYN(dmReserved1);
|
|
|
|
COPYN(dmReserved2);
|
|
|
|
|
|
|
|
/* we're done with 0x400 fields */
|
|
|
|
if (OldSize > SIZEOF_DEVMODEA_400)
|
|
|
|
{
|
|
|
|
COPYN(dmPanningWidth);
|
|
|
|
COPYN(dmPanningHeight);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Restore old size */
|
|
|
|
lpDevMode->dmSize = OldSize;
|
|
|
|
|
|
|
|
/* Extra data presented? */
|
|
|
|
if (lpDevMode->dmDriverExtra && lpExtendedDevMode->dmDriverExtra)
|
|
|
|
{
|
|
|
|
/* We choose the smallest size */
|
|
|
|
if (lpDevMode->dmDriverExtra > lpExtendedDevMode->dmDriverExtra)
|
|
|
|
lpDevMode->dmDriverExtra = lpExtendedDevMode->dmDriverExtra;
|
|
|
|
|
|
|
|
/* Copy extra data */
|
2017-04-24 15:04:00 +00:00
|
|
|
RtlCopyMemory((PUCHAR)lpDevMode + OldSize,
|
|
|
|
lpExtendedDevMode + 1,
|
|
|
|
lpDevMode->dmDriverExtra);
|
2016-09-11 20:11:35 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If the size of source structure is less, than used, we clean unsupported flags */
|
|
|
|
if (OldSize < FIELD_OFFSET(DEVMODEA, dmPanningHeight))
|
|
|
|
lpDevMode->dmFields &= ~DM_PANNINGHEIGHT;
|
|
|
|
|
|
|
|
if (OldSize < FIELD_OFFSET(DEVMODEA, dmPanningWidth))
|
|
|
|
lpDevMode->dmFields &= ~DM_PANNINGWIDTH;
|
|
|
|
|
|
|
|
Result = TRUE;
|
2008-05-11 23:51:55 +00:00
|
|
|
}
|
2016-09-11 20:11:35 +00:00
|
|
|
|
|
|
|
/* Free memory */
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, lpExtendedDevMode);
|
|
|
|
|
|
|
|
return Result;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2003-07-19 01:35:27 +00:00
|
|
|
EnumDisplaySettingsA(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPCSTR lpszDeviceName,
|
|
|
|
DWORD iModeNum,
|
|
|
|
LPDEVMODEA lpDevMode)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2016-09-11 20:11:35 +00:00
|
|
|
/* Fixup sizes */
|
|
|
|
lpDevMode->dmSize = FIELD_OFFSET(DEVMODEA, dmICMMethod);
|
|
|
|
lpDevMode->dmDriverExtra = 0;
|
|
|
|
|
|
|
|
return EnumDisplaySettingsExA(lpszDeviceName, iModeNum, lpDevMode, 0);
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
EnumDisplaySettingsExW(
|
2008-05-11 23:51:55 +00:00
|
|
|
LPCWSTR lpszDeviceName,
|
|
|
|
DWORD iModeNum,
|
|
|
|
LPDEVMODEW lpDevMode,
|
|
|
|
DWORD dwFlags)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2008-05-11 23:51:55 +00:00
|
|
|
NTSTATUS Status;
|
2016-09-11 19:05:27 +00:00
|
|
|
UNICODE_STRING usDeviceName;
|
|
|
|
PUNICODE_STRING pusDeviceName = NULL;
|
|
|
|
LPDEVMODEW lpExtendedDevMode;
|
|
|
|
BOOL Result = FALSE;
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2008-05-11 23:51:55 +00:00
|
|
|
if (lpszDeviceName)
|
|
|
|
{
|
|
|
|
RtlInitUnicodeString(&usDeviceName, lpszDeviceName);
|
|
|
|
pusDeviceName = &usDeviceName;
|
|
|
|
}
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2016-09-11 19:05:27 +00:00
|
|
|
/* Allocate memory for DEVMODEW and extra data */
|
|
|
|
lpExtendedDevMode = RtlAllocateHeap(RtlGetProcessHeap(),
|
|
|
|
HEAP_ZERO_MEMORY,
|
|
|
|
sizeof(DEVMODEW) + lpDevMode->dmDriverExtra);
|
|
|
|
if (!lpExtendedDevMode)
|
|
|
|
return FALSE;
|
|
|
|
|
|
|
|
/* Initialize structure fields */
|
|
|
|
lpExtendedDevMode->dmSize = sizeof(DEVMODEW);
|
|
|
|
lpExtendedDevMode->dmDriverExtra = lpDevMode->dmDriverExtra;
|
|
|
|
|
|
|
|
Status = NtUserEnumDisplaySettings(pusDeviceName, iModeNum, lpExtendedDevMode, dwFlags);
|
|
|
|
if (NT_SUCCESS(Status))
|
|
|
|
{
|
2017-04-24 15:04:00 +00:00
|
|
|
/* Store old structure sizes */
|
2016-09-11 19:05:27 +00:00
|
|
|
WORD OldSize = lpDevMode->dmSize;
|
2017-04-24 15:04:00 +00:00
|
|
|
WORD OldDriverExtra = lpDevMode->dmDriverExtra;
|
2016-09-11 19:05:27 +00:00
|
|
|
|
|
|
|
/* Copy general data */
|
|
|
|
RtlCopyMemory(lpDevMode, lpExtendedDevMode, OldSize);
|
|
|
|
|
2017-04-24 15:04:00 +00:00
|
|
|
/* Restore old sizes */
|
2016-09-11 19:05:27 +00:00
|
|
|
lpDevMode->dmSize = OldSize;
|
2017-04-24 15:04:00 +00:00
|
|
|
lpDevMode->dmDriverExtra = OldDriverExtra;
|
2016-09-11 19:05:27 +00:00
|
|
|
|
|
|
|
/* Extra data presented? */
|
|
|
|
if (lpDevMode->dmDriverExtra && lpExtendedDevMode->dmDriverExtra)
|
|
|
|
{
|
|
|
|
/* We choose the smallest size */
|
|
|
|
if (lpDevMode->dmDriverExtra > lpExtendedDevMode->dmDriverExtra)
|
|
|
|
lpDevMode->dmDriverExtra = lpExtendedDevMode->dmDriverExtra;
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2016-09-11 19:05:27 +00:00
|
|
|
/* Copy extra data */
|
2017-04-24 15:04:00 +00:00
|
|
|
RtlCopyMemory((PUCHAR)lpDevMode + OldSize,
|
|
|
|
lpExtendedDevMode + 1,
|
|
|
|
lpDevMode->dmDriverExtra);
|
2016-09-11 19:05:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
/* If the size of source structure is less, than used, we clean unsupported flags */
|
|
|
|
if (OldSize < FIELD_OFFSET(DEVMODEW, dmPanningHeight))
|
|
|
|
lpDevMode->dmFields &= ~DM_PANNINGHEIGHT;
|
|
|
|
|
|
|
|
if (OldSize < FIELD_OFFSET(DEVMODEW, dmPanningWidth))
|
|
|
|
lpDevMode->dmFields &= ~DM_PANNINGWIDTH;
|
|
|
|
|
|
|
|
Result = TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Free memory */
|
|
|
|
RtlFreeHeap(RtlGetProcessHeap(), 0, lpExtendedDevMode);
|
|
|
|
|
|
|
|
return Result;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
EnumDisplaySettingsW(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPCWSTR lpszDeviceName,
|
|
|
|
DWORD iModeNum,
|
|
|
|
LPDEVMODEW lpDevMode)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2016-09-11 19:05:27 +00:00
|
|
|
/* Fixup sizes */
|
2016-09-11 20:11:35 +00:00
|
|
|
lpDevMode->dmSize = FIELD_OFFSET(DEVMODEW, dmICMMethod);
|
2016-09-11 19:05:27 +00:00
|
|
|
lpDevMode->dmDriverExtra = 0;
|
|
|
|
|
|
|
|
return EnumDisplaySettingsExW(lpszDeviceName, iModeNum, lpDevMode, 0);
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
2003-05-12 19:30:00 +00:00
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2004-11-16 16:29:21 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
GetMonitorInfoA(
|
2011-03-26 01:20:11 +00:00
|
|
|
HMONITOR hMonitor,
|
|
|
|
LPMONITORINFO lpmi)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
if (lpmi->cbSize == sizeof (MONITORINFO))
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
return NtUserGetMonitorInfo(hMonitor, lpmi);
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
2011-03-26 01:20:11 +00:00
|
|
|
else if (lpmi->cbSize != sizeof (MONITORINFOEXA))
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
SetLastError(ERROR_INVALID_PARAMETER);
|
|
|
|
return FALSE;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
2011-03-26 01:20:11 +00:00
|
|
|
else
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
MONITORINFOEXW miExW;
|
|
|
|
INT res;
|
2004-11-16 16:29:21 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
miExW.cbSize = sizeof (MONITORINFOEXW);
|
|
|
|
if (!NtUserGetMonitorInfo(hMonitor, (LPMONITORINFO)&miExW))
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
return FALSE;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
2011-03-26 01:20:11 +00:00
|
|
|
memcpy(lpmi, &miExW, sizeof (MONITORINFO));
|
|
|
|
res = WideCharToMultiByte(CP_THREAD_ACP, 0, miExW.szDevice, -1,
|
|
|
|
((LPMONITORINFOEXA)lpmi)->szDevice, CCHDEVICENAME,
|
|
|
|
NULL, NULL);
|
|
|
|
if (res == 0)
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
WARN("WideCharToMultiByte() failed!\n");
|
|
|
|
return FALSE;
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
return TRUE;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2004-11-16 16:29:21 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2004-01-23 23:38:26 +00:00
|
|
|
BOOL
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
GetMonitorInfoW(
|
2011-03-26 01:20:11 +00:00
|
|
|
HMONITOR hMonitor,
|
|
|
|
LPMONITORINFO lpmi)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
return NtUserGetMonitorInfo(hMonitor, lpmi);
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HMONITOR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2004-11-16 16:29:21 +00:00
|
|
|
MonitorFromPoint(
|
2011-03-26 01:20:11 +00:00
|
|
|
IN POINT ptPoint,
|
|
|
|
IN DWORD dwFlags )
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
return NtUserMonitorFromPoint(ptPoint, dwFlags);
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HMONITOR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2004-11-16 16:29:21 +00:00
|
|
|
MonitorFromRect(
|
2011-03-26 01:20:11 +00:00
|
|
|
IN LPCRECT lpcRect,
|
|
|
|
IN DWORD dwFlags )
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
return NtUserMonitorFromRect(lpcRect, dwFlags);
|
2004-11-16 16:29:21 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
* @implemented
|
|
|
|
*/
|
|
|
|
HMONITOR
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2004-11-16 16:29:21 +00:00
|
|
|
MonitorFromWindow(
|
2011-03-26 01:20:11 +00:00
|
|
|
IN HWND hWnd,
|
|
|
|
IN DWORD dwFlags )
|
2004-11-16 16:29:21 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
return NtUserMonitorFromWindow(hWnd, dwFlags);
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
2003-05-12 19:30:00 +00:00
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2002-06-13 20:36:40 +00:00
|
|
|
LONG
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2003-07-19 01:35:27 +00:00
|
|
|
ChangeDisplaySettingsExA(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPCSTR lpszDeviceName,
|
|
|
|
LPDEVMODEA lpDevMode,
|
|
|
|
HWND hwnd,
|
|
|
|
DWORD dwflags,
|
|
|
|
LPVOID lParam)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
LONG rc;
|
|
|
|
UNICODE_STRING DeviceName;
|
|
|
|
PUNICODE_STRING pDeviceName = &DeviceName;
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
if (lpszDeviceName != NULL)
|
2003-07-19 01:35:27 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
if (!RtlCreateUnicodeStringFromAsciiz(pDeviceName, (PCSZ)lpszDeviceName))
|
2004-07-08 00:46:22 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
SetLastError(ERROR_OUTOFMEMORY);
|
|
|
|
return DISP_CHANGE_BADPARAM; /* FIXME what to return? */
|
2004-07-08 00:46:22 +00:00
|
|
|
}
|
2003-07-19 01:35:27 +00:00
|
|
|
}
|
2011-03-26 01:20:11 +00:00
|
|
|
else
|
|
|
|
pDeviceName = NULL;
|
|
|
|
|
|
|
|
if (lpDevMode != NULL)
|
2010-05-28 21:58:33 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
LPDEVMODEW pDevModeW;
|
|
|
|
pDevModeW = GdiConvertToDevmodeW(lpDevMode);
|
|
|
|
if(pDevModeW)
|
|
|
|
{
|
2015-09-09 19:56:22 +00:00
|
|
|
rc = NtUserChangeDisplaySettings(pDeviceName, pDevModeW, dwflags, lParam);
|
2011-03-26 01:20:11 +00:00
|
|
|
RtlFreeHeap(GetProcessHeap(), 0, pDevModeW);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
rc = DISP_CHANGE_SUCCESSFUL;
|
2010-05-28 21:58:33 +00:00
|
|
|
}
|
|
|
|
else
|
2015-09-09 19:56:22 +00:00
|
|
|
rc = NtUserChangeDisplaySettings(pDeviceName, NULL, dwflags, lParam);
|
2009-06-12 16:52:31 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
if (lpszDeviceName != NULL)
|
|
|
|
RtlFreeUnicodeString(&DeviceName);
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
return rc;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2002-06-13 20:36:40 +00:00
|
|
|
LONG
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2003-07-19 01:35:27 +00:00
|
|
|
ChangeDisplaySettingsA(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPDEVMODEA lpDevMode,
|
|
|
|
DWORD dwflags)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
if(lpDevMode)
|
|
|
|
lpDevMode->dmDriverExtra = 0;
|
|
|
|
return ChangeDisplaySettingsExA ( NULL, lpDevMode, NULL, dwflags, 0 );
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2002-06-13 20:36:40 +00:00
|
|
|
LONG
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
ChangeDisplaySettingsExW(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPCWSTR lpszDeviceName,
|
|
|
|
LPDEVMODEW lpDevMode,
|
|
|
|
HWND hwnd,
|
|
|
|
DWORD dwflags,
|
|
|
|
LPVOID lParam)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
LONG rc;
|
|
|
|
UNICODE_STRING DeviceName;
|
|
|
|
PUNICODE_STRING pDeviceName = &DeviceName;
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
if (lpszDeviceName != NULL)
|
|
|
|
RtlInitUnicodeString(pDeviceName, lpszDeviceName);
|
|
|
|
else
|
|
|
|
pDeviceName = NULL;
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2015-09-09 19:56:22 +00:00
|
|
|
rc = NtUserChangeDisplaySettings(pDeviceName, lpDevMode, dwflags, lParam);
|
2003-07-19 01:35:27 +00:00
|
|
|
|
2011-03-26 01:20:11 +00:00
|
|
|
return rc;
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|
|
|
|
|
2003-07-10 21:04:32 +00:00
|
|
|
|
|
|
|
/*
|
2003-07-19 01:35:27 +00:00
|
|
|
* @implemented
|
2003-07-10 21:04:32 +00:00
|
|
|
*/
|
2002-06-13 20:36:40 +00:00
|
|
|
LONG
|
2008-11-30 11:42:05 +00:00
|
|
|
WINAPI
|
2002-06-13 20:36:40 +00:00
|
|
|
ChangeDisplaySettingsW(
|
2011-03-26 01:20:11 +00:00
|
|
|
LPDEVMODEW lpDevMode,
|
|
|
|
DWORD dwflags)
|
2002-06-13 20:36:40 +00:00
|
|
|
{
|
2011-03-26 01:20:11 +00:00
|
|
|
if(lpDevMode)
|
|
|
|
lpDevMode->dmDriverExtra = 0;
|
|
|
|
return ChangeDisplaySettingsExW(NULL, lpDevMode, NULL, dwflags, 0);
|
2002-06-13 20:36:40 +00:00
|
|
|
}
|