News | Articles | Libraries | Developer Tools | Books | Forum Links | Search   
Sections:
 

QA: How to rotate the screen dynamically on Windows Mobile 2003 SE?

By Nicholas Tsipanov, May 28, 2004.
Print version

Question

How can I get what is current screen mode (portrait or landscape) from my program on Windows Mobile 2003 SE devices? I also wand to change it from my program. Is it possible?

Answer

Starting with Windows CE 4.0 the DEVMODE structure got a new field: dmDisplayOrientation. With this field you can query or set the rotation mode.

The values are DMDO_0 (not rotated), DMDO_90 (right-handed landscape mode), DMDO_180 (rotated upside-down) and DMDO_270 (left-handed landscape mode).

To change the display orientation mode call ChangeDisplaySettingsEx:

DEVMODE devmode = {0}; devmode.dmSize = sizeof(DEVMODE); devmode.dmDisplayOrientation = DMDO_90; //landscape mode devmode.dmFields = DM_DISPLAYORIENTATION; ChangeDisplaySettingsEx(NULL, &devmode, NULL, 0, NULL);

And to query the current mode use code:

DEVMODE devmode = {0}; devmode.dmSize = sizeof(DEVMODE); devmode.dmFields = DM_DISPLAYORIENTATION; ChangeDisplaySettingsEx(NULL, &devmode, 0, CDS_TEST, NULL);

The devmode.dmDisplayOrientation will contain the current display orientation mode.

Note that changes made using such calls are not persistent, after soft-reset display mode will return to the previous state.

To make your changes permanent store them in registry. There are two values in registry under HKEY_LOCAL_MACHINE\System\GDI\Rotation key where the system takes its orientation mode on startup:

  • Angle - DWORD value holding rotation angle in degrees. Valid values are 0, 90, 180, 270.
  • LandscapeMode - DWORD value holding flag of landscape mode. Valid values: 0 (portrait mode) and 1 (landscape mode).
It seems like the LandscapeMode is not in use, at least I tried Angle = 180 and LandscapeMode = 1 and the system was working in portrait mode but rotated upside down.

Related resources:

Discuss

Discuss this article. Here you can write your comments and read comments of other developers.
Rate this article:     Poor Excellent    
 12345 
© 2001-2005 Pocket PC Developer Network, a division of Spb Software House