Freigeben über


Rotating the Contents of the Screen (Windows CE 5.0)

Send Feedback

Windows CE 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. Screen rotation is currently supported only on devices that use a single screen and is not supported on multiple screen devices.

An application calls the ChangeDisplaySettingsEx function 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 dmFields member of a DEVMODE structure to DM_DISPLAYQUERYORIENTATION.

  2. Call ChangeDisplaySettingsEx with the lpMode parameter set to the DEVMODE structure and the dwFlags parameter set to CDS_TEST. The following code example shows how to call ChangeDisplaySettingsEx.

    bCanRotate = ChangeDisplaySettingsEx(NULL, &devMode, NULL, CDS_TEST, 
                                         NULL);
    
  3. When ChangeDisplaySettingsEx returns, examine the dmDisplayOrientation member of the DEVMODE structure 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.dmDisplayOrientation only contains DMDO_0 then screen rotation is not supported.

To obtain the current angle of rotation

  1. Set the dmFields member of a DEVMODE structure to DM_DISPLAYORIENTATION.

  2. Call ChangeDisplaySettingsEx with the lpMode parameter set to the DEVMODE structure and the dwFlags parameter set to CDS_TEST. The following code example shows how to call ChangeDisplaySettingsEx.

    ChangeDisplaySettingsEx(NULL, &devMode, NULL, CDS_TEST, NULL);
    
  3. When ChangeDisplaySettingsEx returns, examine the dmDisplayOrientation member of the DEVMODE structure 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 dmFields member of a DEVMODE structure to DM_DISPLAYORIENTATION.
  2. Set the dmDisplayOrienation member of the DEVMODE structure 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 ChangeDisplaySettingsEx with the lpMode parameter set to the DEVMODE structure and the dwFlags parameter 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.

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

Graphics Device Interface (GDI) | How to Implement Screen Rotation

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.