Results 1 to 3 of 3

Thread: VB.Net ScreenOrientation.Angle180

  1. #1
    Low Bitrate Thelgord's Avatar
    Join Date
    Jan 2007
    Location
    Wahiawa, HI
    Posts
    67

    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%


  2. #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

  3. #3
    Low Bitrate Thelgord's Avatar
    Join Date
    Jan 2007
    Location
    Wahiawa, HI
    Posts
    67
    Thanks, thats exactly what i was lookng for


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


Similar Threads

  1. vb.net code for volume control
    By takissd in forum Software & Software Development
    Replies: 17
    Last Post: 12-27-2008, 05:19 PM
  2. build control in vb.net 2005
    By takissd in forum Coders Corner
    Replies: 24
    Last Post: 12-13-2005, 02:23 PM
  3. Destinator SDK VB.Net
    By TommyGun in forum Software & Software Development
    Replies: 0
    Last Post: 10-08-2005, 04:35 AM
  4. quick vb.net and wmp ?
    By pimpJ in forum Software & Software Development
    Replies: 16
    Last Post: 10-29-2004, 01:23 PM
  5. VB.net and FMOD
    By bondbond55 in forum Software & Software Development
    Replies: 0
    Last Post: 03-12-2004, 11:56 AM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •