ChangeDisplaySettingsEx (Windows Embedded CE 6.0)

1/6/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 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. The following table shows the members of the DEVMODE structure that you can use.

    Value Description

    dmPelsWidth

    For Windows Embedded CE 6.0 and later versions, this value indicates pixel width.

    dmPelsHeight

    For Windows Embedded CE 6.0 and later versions, this value indicates pixel height.

    dmDisplayOrientation

    Screen rotation.

    Screen rotation is not supported on platforms with multiple screens.

    Setting the dmBitsPerPel member is not supported.

    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.

    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 dmDisplayOrientation value to change the orientation of the screen.

    DM_PELSWIDTH

    For Windows Embedded CE 6.0 and later versions, this value indicates to use the dmPelsWidth value.

    DM_PELSHEIGHT

    For Windows Embedded CE 6.0 and later versions, this value indicates to use the dmPelsHeight value.

    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.

  • hwnd
    [in] Reserved; must be NULL.
  • dwflags
    [in] DWORD that 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 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_VIDEOPARAMETERS

    Indicates that the lParam parameter is a pointer to a VIDEOPARAMETERS structure.

  • lParam
    [in] Pointer to a VIDEOPARAMETERS structure if dwFlags is 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 dwFlags parameter.

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

ChangeDisplaySettingsEx was 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_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.

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

See Also

Reference

GDI Functions
CreateDC
DEVMODE
EnumDisplaySettings