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

Windows Mobile allows you to rotate the content displayed on a screen in increments of 90 degrees. Screen rotation requires support from the display driver, which maintains information regarding rotation.

An application calls the ChangeDisplaySettingsExfunction to determine the screen orientation modes that the system supports, to set the angle by which the screen is rotated, and to query the current angle of rotation.

To determine whether the driver supports screen rotation
  1. Set the dmFieldsmember of a DEVMODEstructure to DM_DISPLAYQUERYORIENTATION.

  2. Call ChangeDisplaySettingsExwith the lpModeparameter set to the DEVMODEstructure and the dwFlagsparameter set to CDS_TEST. The following code example shows how to call ChangeDisplaySettingsEx.

    Copy Code
    bCanRotate = ChangeDisplaySettingsEx(NULL, &devMode, NULL,
    CDS_TEST, 
    									 NULL);
    
  3. When ChangeDisplaySettingsExreturns, examine the dmDisplayOrientationmember of the DEVMODEstructure to determine the rotation angels that driver supports. This member's value will be a combination of one or more of the values shown in the following table.

    Value Description

    DMDO_0

    Rotation by 0 degrees is supported.

    DMDO_90

    Rotation by 90 degrees counterclockwise is supported.

    DMDO_180

    Rotation by 180 degrees is supported.

    DMDO_270

    Rotation by 270 degrees counterclockwise is supported.

    If DEVMODE.dmDisplayOrientationonly contains DMDO_0 then screen rotation is not supported.

To obtain the current angle of rotation
  1. Set the dmFieldsmember of a DEVMODEstructure to DM_DISPLAYORIENTATION.

  2. Call ChangeDisplaySettingsExwith the lpModeparameter set to the DEVMODEstructure and the dwFlagsparameter set to CDS_TEST. The following code example shows how to call ChangeDisplaySettingsEx.

    Copy Code
    ChangeDisplaySettingsEx(NULL, &devMode, NULL, CDS_TEST, NULL);
    
  3. When ChangeDisplaySettingsExreturns, examine the dmDisplayOrientationmember of the DEVMODEstructure to determine the current angle of rotation. The following table shows the possible values of this member.

    Value Description

    DMDO_0

    The screen is not rotated.

    DMDO_90

    The screen is rotated by 90 degrees counterclockwise.

    DMDO_180

    The screen is rotated by 180 degrees.

    DMDO_270

    The screen is rotated by 270 degrees counterclockwise.

To set the angle of screen rotation
  1. Set the dmFieldsmember of a DEVMODEstructure to DM_DISPLAYORIENTATION.

  2. Set the dmDisplayOrienationmember of the DEVMODEstructure to the value for the angle of rotation you want. The following table shows the possible values.

    Value Description

    DMDO_90

    Rotate the screen by 90 degrees counterclockwise.

    DMDO_180

    Rotate the screen by 180 degrees.

    DMDO_270

    Rotate the screen by 270 degrees counterclockwise.

  3. Call ChangeDisplaySettingsExwith the lpModeparameter set to the DEVMODEstructure and the dwFlagsparameter set to CDS_RESET.

The following code example shows how to set the angle of screen rotation to 180 degrees, which displays the content of the screen upside-down.

Copy Code
devMode.dmFields = DM_DISPLAYORIENTATION;
devMode.dmDisplayOrientation = DMDO_180;
ChangeDisplaySettingsEx(NULL,&devMode,NULL,CDS_RESET,NULL);

When the screen is rotated, the OS notifies the following parts of the system about the new screen resolution:

  • Touch driver. The touch driver maintains information about the rotation angle of the screen. If the screen is rotated, GWES performs the necessary transformation of the coordinates for the new orientation.

  • Cursor and mouse.

  • Window manager. The window manager sends a WM_SETTINGCHANGEmessage to the taskbar, which causes the taskbar to change its size to match the new screen resolution and updates all structures related to the screen resolution. The window manager also invalidates and forces the redrawing of all regions when the screen resolution changes because the screen was rotated.

The OS notifies an application about changes in screen rotation by sending a WM_SETTINGSCHANGE message to the applications. The application is responsible for responding to the new screen resolution and repainting any windows that the application created. If the application does not respond to the orientation change, the windows created by the application could become positioned outside of the current screen coordinates. An application should respond to this message by changing the size and position of its windows to match the new screen resolution.

See Also

Concepts

Graphics Device Interface (GDI)

Other Resources