Implement screen rotation (screen rotation) in WinCE)

Source: Internet
Author: User

Screen rotation is performed in wince. First, check whether the driver of the display device supports the screen rotation function. Screen rotation can be performed in either of the following ways:

1. Modify the registry for rotation.

By default, the screen is displayed normally, that is, the flip angle is 0 degrees. You can flip the screen by modifying the registry and modifying the "angle" value. The specific settings are as follows:

[Hkey_local_machinesystemgdirotation]

"Angle" = DWORD: 5A; Flip 90 degrees, Roman, 5A is the hexadecimal System of 90

It can be set to 0 degrees, 90 degrees, 180 degrees, and 270 degrees. 0, 5a, B4, and 10E can be used to flip the screen. You can do this when you build an image, as long as it is in the project. add the above settings to the reg file, and then re-make image. After the new image is started, it will be displayed according to your settings. You can also compile a small read/write registry after Windows is started.ProgramTo modify the value, and then restart (the system must support hive-based registry ).

2. Perform rotation through changedisplaysettingex (...)

It should be said that this function is used to change the display settings. For details, see msdn. Let me talk about it briefly:

The function is as follows:

Long changedisplaysettingsex (
Lpctstr lpszdevicename,
Lpdevmode,
Hwnd,
DWORD dwflags,
Lpvoid lparam
);

Lpszdevicename: not used, set to null.

Lpdevmode: a pointer to a devmode structure.

Hwnd: Reserved. Must be set to null.

Dwflags: 0: The current screen graphics mode can be dynamically changed

Cds_reset: changes the request settings, even if they are the same as the current settings.

Cds_test: if the requested graphic mode is set, the system tests the request.

Cds_videoparameters: If this parameter is set, lparam transmits a pointer to the videoparameters structure.

Lparam: If dwflags is set to cds_videoparameters, a pointer to the videoparameters structure is passed in; otherwise, it is set to null.

The devmode structure is still quite complex. It is generally not used in CE. Here I will only introduce a few of the ones I use:

Dwsize: the size of the devmode structure, which is set to sizeof (devmode ).

Dmfields: Initialize the tag bit. During rotation, dm_displayqueryorientation and dm_displayorientation are used. The previous one is used to query whether the current display driver supports rotation, and the last one is used to flip the screen.

Dmdisplayorientation: sets the flip angle. The details are as follows:

Dmdo_0 the screen is rotated by 0 degrees.
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.

 

Generally, when we call this function for rotation in wince, we first determine whether the current device supports rotation. If the device supports rotation, we can perform the rotation operation, the following program flipped the screen to 270 degrees. The program is as follows:

Bool setrotation () {devmode = {0}; devmode. dmsize = Sizeof (Devmode); devmode. dmdisplayorientation = dmdo_270; devmode. dmfields = dm_displayqueryorientation; If (Disp_change_successful! = Changedisplaysettingsex (null, & devmode, null, cds_test, null) {afxmessagebox (_ T ( "Not support !!! " )); Return False;} devmode. dmfields = dm_displayorientation; If (Disp_change_successful! = Changedisplaysettingsex (null, & devmode, null, cds_test, null) {afxmessagebox (_ T ( "Not support !!! " )); Return False ;} Switch (Changedisplaysettingsex (null, & devmode, null, cds_reset, null )){ Case Disp_change_successful: Break ; Case Disp_change_badflags: afxmessagebox (L "Bad flags! " ); Break ; Case Disp_change_badmode: afxmessagebox (L "Bad mode! " ); Break ; Case Disp_change_badparam: afxmessagebox (L "Badparam! " ); Break ; Case Disp_change_notupdated: afxmessagebox (L "Notupdated! " ); Break ; Case Disp_change_restart: afxmessagebox (L "Restart! " ); Break ; Default : Afxmessagebox (L "Default! " ); Break ;} Return True ;}

either of the above methods can implement screen rotation. The first method, by modifying the registry, cannot implement rotation immediately. It takes effect only after the device reboot. The second method does not need to be restarted. After the function is called successfully, the screen will be flipped, but the default value will be restored after the next start.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.