Changing Display Orientation in Windows Mobile

Download the source code

To change the display orientation of a Windows Mobile device, we can use the API ChangeDisplaySettingsEx. The syntax of the ChangeDisplaySettingsEx API is

LONG ChangeDisplaySettingsEx(LPCTSTR lpszDeviceName,LPDEVMODE lpDevMode,HWND hwnd, DWORD dwflags,LPVOID lParam);

The first parameter is the name of the device we want to change, we can use EnumDisplayDevices API to enumerate the devices. The second parameter is a pointer to the DEVMODE structure. It is very impotent to set the dmSize member to the size of the DEVMODE structure. Other members can be used to get and set the display properties. The third parameter is should be NULL and is reserved for future use. The last parameter dwFlags can contain one of the following values


The dmDisplayOrientation member of the DEVMODE structure is used to get and set the display orientation property. This member can have one of the following values, DMDO_0, DMDO_90, DMDO_180, DMDO_270. To find out the supported Screen Orientations we set the dmFields member of the DEVMOE to DM_DISPLAYQUERYORIENTATION value and call the API. If the call is successful the dmDisplayOrientation of the DEVMODE will contain the supported modes. We can perform bit-wise operation to find the supported modes.

The sample application displays four radio buttons and clicking on these buttons will change the screen orientation. This is created using Microsoft Visual Studio 2008.

Leave a Reply

Your email address will not be published. Required fields are marked *