旋转屏幕内容的方向 [英文]

Microsoft Windows CE .NET 4.2 

Rotating the Content of the Screen

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. Examine the return value from ChangeDisplaySettingsEx. If the return value is DISP_CHANGE_SUCCESSFUL, the driver supports screen rotation. If the return value is DISP_CHANGE_BADMODE, the driver does not support screen rotation.

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. 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.
    ValueDescription
    DMDO_0The screen is not rotated.
    DMDO_90The screen is rotated by 90 degrees counterclockwise.
    DMDO_180The screen is rotated by 180 degrees counterclockwise.
    DMDO_270The 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.
    ValueDescription
    DMDO_90Rotate the screen by 90 degrees counterclockwise.
    DMDO_180Rotate the screen by 180 degrees counterclockwise.
    DMDO_270Rotate 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

How to Implement Screen Rotation



 Last updated on Tuesday, July 13, 2004

© 1992-2003 Microsoft Corporation. All rights reserved.

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值