Important:
This is retired content. This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies. This content may contain URLs that were valid when originally published, but now link to sites or pages that no longer exist.
A version of this page is also available for
4/8/2010

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

Syntax

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

Parameters

lpszDeviceName

[in] Not used. Set to NULL.

lpDevMode

[in, out] Pointer to a DEVMODEstructure that describes the new graphics mode.

If lpDevModeis NULL, ChangeDisplaySettingsExuses all of the values currently in the registry for the display setting.

Passing NULL for the lpDevModeparameter and 0 for the dwFlagsparameter is the easiest way to return to the default mode after a dynamic mode change.

You must initialize the dmSizemember of the DEVMODEstructure with the size, in bytes, of the structure. The following table shows the members of the DEVMODEstructure that you can use.

Value Description

dmDisplayOrientation

Screen rotation.

Setting the dmBitsPerPelmember is not supported.

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

Value Description

DM_DISPLAYQUERYORIENTATION

Check 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_DISPLAYORIENTATION

Use the dmDisplayOrientationvalue to change the orientation of the screen.

To ensure that the DEVMODEstructure passed to ChangeDisplaySettingsExis valid and contains only values supported by the display driver, use the DEVMODEreturned by the EnumDisplaySettingsfunction.

hwnd

[in] Reserved; must be NULL.

dwflags

[in] DWORDthat indicates how you want to change the graphics mode. The following table shows the possible values.

Value Description

0

Changes the graphics mode for the current screen dynamically.

CDS_RESET

Changes the settings even if the requested settings are the same as the current settings.

CDS_TEST

Tests if ChangeDisplaySettingsExcan 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_VIDEOPARAMETERS

Indicates that the lParamparameter is a pointer to a VIDEOPARAMETERSstructure.

lParam

[in] Pointer to a VIDEOPARAMETERSstructure if dwFlagsis CDS_VIDEOPARAMETERS. Otherwise, set to NULL.

Return Value

The following table shows the possible return values.

Value Description

DISP_CHANGE_SUCCESSFUL

The settings change was successful.

DISP_CHANGE_BADFLAGS

An invalid set of values was used in the dwFlagsparameter.

DISP_CHANGE_BADMODE

The graphics mode is not supported.

DISP_CHANGE_BADPARAM

An invalid parameter was used.

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

DISP_CHANGE_FAILED

The display driver failed the specified graphics mode.

DISP_CHANGE_NOTUPDATED

ChangeDisplaySettingsExwas unable to write settings to the registry.

DISP_CHANGE_RESTART

The user must restart the computer for the graphics mode to work.

Remarks

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

To query for the current orientation, call ChangeDisplaySettingsExwith lpDevModeset to DM_DISPLAYORIENTATION and dwflagsset 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.

Parameter Value

wParam

SETTINGCHANGE_RESET

lParam

0

Using the dmFields flag of DM_DISPLAYORIENTATION, ChangeDisplaySettingsEx can be used to dynamically rotate the screen orientation. For operating systems based on Windows CE 5.0 and earlier versions, the DM_PELSWIDTH and DM_PELSHEIGHT flags cannot be used to change the screen resolution.

Requirements

Header windows.h
Library coredll.lib
Windows Embedded CE Windows CE .NET 4.0 and later
Windows Mobile Windows Mobile Version 5.0 and later

See Also