The MP3car.com Store The MP3car.com Store    

Sponsored links

Go Back   MP3Car.com > Mp3Car Technical > Software & Software Development > Coders Corner

Reply
 
LinkBack Thread Tools Display Modes
Old 08-13-2007, 08:17 PM   #1
Low Bitrate
 
Thelgord's Avatar
 
Join Date: Jan 2007
Posts: 57
VB.Net ScreenOrientation.Angle180

I know how to get the current the current screen orentation. The questions is how do i set it and make the screen rotate programatically.

I have been searching like crazy for a while now with no luck. I have found solutions for windows mobile and windows CE but not for windows XP/Vista. I know this can be done on my laptop, because there is a utility burried in control panel that I can use to change it. I want to write a small app that will change it on the fly.

Thanks for any responce.<br /><br />
__________________


CarPuter
----------------------------
Planning....[||||||||||]60%
Parts.......[||||||||||]20%
Construction[||||||||||]0%
Software....[||||||||||]0%

Thelgord is offline   Reply With Quote
Advertisement
 
Advertisement
Sponsored links

Old 09-05-2007, 10:09 AM   #2
Low Bitrate
 
Join Date: Nov 2006
Location: Huntsville, AL
Posts: 73
Hi Thelgord,

I was trying to do the same thing with C# on my laptop. The screen swivels and re-closes into tablet form with buttons on the front panel, one of which is supposed to rotate the screen. The software for the buttons only worked right in Vista, but I loaded XP. After some scanning using regmon, I discovered that the HP software was registering the button presses, but the screen wasn't being rotated.

My laptop has an Nvidia graphics chipset, so I was able to use an interop call to nvcpl.
Code:
[DllImport("nvcpl.dll", CharSet=CharSet.Ansi)] public static extern bool dtcfgex(string nvCommand);

My native screen resolution is 1280x800, so I determine first determine the screen height. If it's 800, I rotate to 270-deg (portrait). If it's 1280, I rotate the screen to 0-deg (normal).
Code:
private static void UpdateCurrentSettings() { // helper to update the UI with current settings DEVMODE dm = NativeMethods.CreateDevmode(); bool bSuccess = false; GetSettings(ref dm); if (dm.dmPelsHeight == 800 && dm.dmPelsWidth == 1280) { bSuccess = NativeMethods.dtcfgex("rotate 1 270"); } if (dm.dmPelsHeight == 1280 && dm.dmPelsWidth == 800) { bSuccess = NativeMethods.dtcfgex("rotate 1 0"); } }

I have a "NativeMethods" class that contains the interop calls
Code:
// PInvoke declaration for EnumDisplaySettings Win32 API [DllImport("user32.dll", CharSet=CharSet.Ansi)] public static extern int EnumDisplaySettings(string lpszDeviceName, int iModeNum, ref DEVMODE lpDevMode); // PInvoke declaration for ChangeDisplaySettings Win32 API [DllImport("user32.dll", CharSet=CharSet.Ansi)] public static extern int ChangeDisplaySettings(ref DEVMODE lpDevMode, int dwFlags); // helper for creating an initialized DEVMODE structure public static DEVMODE CreateDevmode() { DEVMODE dm = new DEVMODE(); dm.dmDeviceName = new String(new char[32]); dm.dmFormName = new String(new char[32]); dm.dmSize = (short)Marshal.SizeOf(dm); return dm; }

Note that the "ChangeDisplaySettings" function still exists in my code, but I could never actually get it working right.

The app is as simple as possible. When it runs it gets the screen height, rotates the display accordingly, then exits. Of course, it only works for Nvidia cards.

If you like, I can dump the full source code on my website and post a link.

Hope this helps,
pb
pbarrette is offline   Reply With Quote
Old 09-15-2007, 07:51 AM   #3
Low Bitrate
 
Thelgord's Avatar
 
Join Date: Jan 2007
Posts: 57
Thanks, thats exactly what i was lookng for
__________________


CarPuter
----------------------------
Planning....[||||||||||]60%
Parts.......[||||||||||]20%
Construction[||||||||||]0%
Software....[||||||||||]0%

Thelgord is offline   Reply With Quote
Sponsored links
Advertisement
 
Advertisement
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are Off
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
vb.net code for volume control takissd Software & Software Development 16 07-09-2006 10:32 AM
build control in vb.net 2005 takissd Coders Corner 24 12-13-2005 01:23 PM
Destinator SDK VB.Net TommyGun Software & Software Development 0 10-08-2005 03:35 AM
quick vb.net and wmp ? pimpJ Software & Software Development 16 10-29-2004 12:23 PM
VB.net and FMOD bondbond55 Software & Software Development 0 03-12-2004 10:56 AM


All times are GMT -5. The time now is 11:12 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.2.0
Copyright © 1999 - 2008 Mp3Car.com Inc.Ad Management by RedTyger
Message Board Statistics