How to Change the Display Orientation?

10 05 2009


Are you using Windows XP? Press Ctrl+Atl+DownArrow, and then Ctrl+Atl+UpArrow. The screen changes its orientation upside down. isn’t it? But how to turn the screen, upside down programmatically?

ChangeDisplayOrientation
Image Courtesy – marieforleo.com


Get the current DEVMODE by calling –EnumDisplaySettings(). Then change orientation by setting DEVMODE.dmDisplayOrientation and calling ChangeDisplaySettings(). Have a look at the code snippet. Code taken from MSDN.

// Get current Device Mode.
DEVMODE DeviceMode = { 0 };
EnumDisplaySettings( NULL,
 ENUM_CURRENT_SETTINGS,
 &DeviceMode );

// Change display mode upside down.
DeviceMode.dmDisplayOrientation = DMDO_180;
ChangeDisplaySettings( &DeviceMode, 0 );

// Sleep for 10 seconds.
Sleep( 10000 );

// Change display mode back.
DeviceMode.dmDisplayOrientation = DMDO_DEFAULT;
ChangeDisplaySettings( &DeviceMode, 0 );


Be careful to restore the display orientation back. Or else 😉


Targeted Audiance – Intermeidate.

Advertisements

Actions

Information

4 responses

26 05 2009
Ben L

What are you talking about? I have XP and ctrl+alt+down,ctrl+alt+up does nothing. Where did you get this information?

31 05 2009
pslacerda

this site have a lot of fun and great articles, thanks

8 06 2009
14 06 2009
Jijo.Raj

Hi leochou,

Thanks for the link! Keep watching!

Regards,
Jijo.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s




%d bloggers like this: