ChangeDisplaySettingsEx (Windows CE 5.0)

Windows CE 5.0
Send Feedback

This function changes the settings of the specified display device to the specified graphics mode.

LONG ChangeDisplaySettingsEx(
  LPCTSTR lpszDeviceName,
  LPDEVMODE lpDevMode,
  HWND hwnd,
  DWORD dwflags,
  LPVOID lParam


[in] Not used. Set to NULL.
[in, out] Pointer to a DEVMODE structure that describes the new graphics mode.

If lpDevMode is NULL, ChangeDisplaySettingsEx uses all of the values currently in the registry for the display setting.

Passing NULL for the lpDevMode parameter and 0 for the dwFlags parameter is the easiest way to return to the default mode after a dynamic mode change.

You must initialize the dmSize member of the DEVMODE structure with the size, in bytes, of the structure. In addition, you can set the dmDisplayOrientation member if you want to rotate the screen.

Screen rotation is not supported on platforms with multiple screens.   

The following table shows the values in the dmFields member that you must also set to change the display settings, in addition to using one or more of the preceding DEVMODE members.

DM_DISPLAYQUERYORIENTATIONCheck whether the display driver supports screen rotation.

The supported screen orientations are returned in lpDevMode.dmDisplayOrientation.

A value of just DMO_0 indicates that screen rotation is not supported.

DM_DISPLAYORIENTATIONUse the dmDisplayOrientation value to change the orientation of the screen.

To ensure that the DEVMODE structure passed to ChangeDisplaySettingsEx is valid and contains only values supported by the display driver, use the DEVMODE returned by the EnumDisplaySettings function.

[in] Reserved; must be NULL.
[in] DWORD that indicates how you want to change the graphics mode. The following table shows the possible values.
0Changes the graphics mode for the current screen dynamically.
CDS_RESETChanges the settings even if the requested settings are the same as the current settings.
CDS_TESTTests if ChangeDisplaySettingsEx can set the requested graphics mode.

Specifying CDS_TEST allows an application to determine which graphics modes are actually valid, without causing the system to change to the settings.

CDS_VIDEOPARAMETERSIndicates that the lParam parameter is a pointer to a VIDEOPARAMETERS structure.
[in] Pointer to a VIDEOPARAMETERS structure if dwFlags is CDS_VIDEOPARAMETERS. Otherwise, set to NULL.

Return Values

The following table shows the possible return values.

DISP_CHANGE_SUCCESSFULThe settings change was successful.
DISP_CHANGE_BADFLAGSAn invalid set of values was used in the dwFlags parameter.
DISP_CHANGE_BADMODEThe graphics mode is not supported.
DISP_CHANGE_BADPARAMAn invalid parameter was used.

This error can include an invalid value or combination of values.

DISP_CHANGE_FAILEDThe display driver failed the specified graphics mode.
DISP_CHANGE_NOTUPDATEDChangeDisplaySettingsEx was unable to write settings to the registry.
DISP_CHANGE_RESTARTThe user must restart the computer for the graphics mode to work.


When you change the display mode dynamically, the OS sends the WM_SETTINGCHANGE message to all running applications.

To query for the current orientation, call ChangeDisplaySettingsEx with lpDevMode set to DM_DISPLAYORIENTATION and dwflags set to CDS_TEST. The current orientation will be returned in lpDevMode.

The following table shows the value of the parameters that the OS uses when it sends this message.


Using the dmFields flag of DM_DISPLAYORIENTATION, ChangeDisplaySettingsEx can be used to dynamically rotate the screen orientation. However, the DM_PELSWIDTH and DM_PELSHEIGHT flags cannot be used to change the screen resolution.


OS Versions: Windows CE .NET 4.0 and later.
Header: Windows.h.
Link Library: Coredll.lib.

See Also

CreateDC | DEVMODE | EnumDisplaySettings

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.