469,296 Members | 2,111 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,296 developers. It's quick & easy.

To rotate screen under WinXP

Hi,

I'm not sure, but reference MSDN ChangeDisplaySettingsEx can rotate screen
if video driver support it. I try the third part products like IRotate and
Pivot Pro and find that it really works. I have ATI (AMD) video and
Catalist driver can rotate screen easy as well.

I try to do in vb.net and ChangeDisplaySettingsEx can change resolution,
frequancy and other setting exept rotation:-(
Searching in Internet don't give any solution, but some developers found the
same problem. Could anybody explain me, how to do it correct? Code:

Imports System.Runtime.InteropServices

Imports System

Module Module1

Private Const CCDEVICENAME = 32

Private Const CCFORMNAME = 32

Private Const ENUM_CURRENT_SETTINGS = -1

Private Const DMDO_DEFAULT = 0

Private Const DMDO_90 = 1

Private Const DMDO_180 = 2

Private Const DMDO_270 = 3

Private Const DM_ORIENTATION = &H1 ' PRINTER

Private Const DM_PAPERSIZE = &H2 ' PRINTER

Private Const DM_PAPERLENGTH = &H4 ' PRINTER

Private Const DM_PAPERWIDTH = &H8 ' PRINTER

Private Const DM_SCALE = &H10 ' PRINTER

Private Const DM_POSITION = &H20

Private Const DM_NUP = &H40

Private Const DM_DISPLAYORIENTATION = &H80 ' DISPLAY -- XP only

Private Const DM_COPIES = &H100 ' PRINTER

Private Const DM_DEFAULTSOURCE = &H200 ' PRINTER

Private Const DM_PRINTQUALITY = &H400 ' PRINTER

Private Const DM_COLOR = &H800 ' PRINTER

Private Const DM_DUPLEX = &H1000 ' PRINTER

Private Const DM_YRESOLUTION = &H2000 ' PRINTER

Private Const DM_TTOPTION = &H4000 ' PRINTER

Private Const DM_COLLATE = &H8000 ' PRINTER

Private Const DM_FORMNAME = &H10000 ' PRINTER

Private Const DM_LOGPIXELS = &H20000

Private Const DM_BITSPERPEL = &H40000 ' DISPLAY

Private Const DM_PELSWIDTH = &H80000 ' DISPLAY

Private Const DM_PELSHEIGHT = &H100000 ' DISPLAY

Private Const DM_DISPLAYFLAGS = &H200000 ' DISPLAY

Private Const DM_DISPLAYFREQUENCY = &H400000 ' DISPLAY

Private Const DM_ICMMETHOD = &H800000

Private Const DM_ICMINTENT = &H1000000

Private Const DM_MEDIATYPE = &H2000000

Private Const DM_DITHERTYPE = &H4000000

Private Const DM_PANNINGWIDTH = &H8000000

Private Const DM_PANNINGHEIGHT = &H10000000

Private Const DM_DISPLAYFIXEDOUTPUT = &H20000000 ' XP only

Private Const DISP_CHANGE_SUCCESSFUL = 0

Private Const DISP_CHANGE_FAILED = -1

Private Const DISP_CHANGE_BADMODE = -2

Private Const DISP_CHANGE_NOTUPDATED = -3

Private Const DISP_CHANGE_BADFLAGS = -4

Private Const DISP_CHANGE_BADPARAM = -5

Private Const DISP_CHANGE_BADDUALVIEW = -6

Private Const DISP_CHANGE_RESTART = 1

Private Const CDS_UPDATEREGISTRY = &H1

Private Const CDS_FULLSCREEN = &H4

Private Const CDS_GLOBAL = &H8

Private Const CDS_SET_PRIMARY = &H10

Private Const CDS_TEST = &H4

Private Const CDS_RESET = &H40000000

Private Const CDS_SETRECT = &H20000000

Private Const CDS_VIDEOPARAMETERS = &H20

Private Const CDS_NORESET = &H10000000

Private Const CDS_FORCE = &H80000000

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)_

Private Structure DISPLAY_DEVICE

Public cb As Integer

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=32)Public DeviceName As
String

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)Public DeviceString As
String

Public StateFlags As Integer

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)Public DeviceID As
String

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=128)Public DeviceKey As
String

End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)_

Private Structure POINTL

Public x As Integer

Public y As Integer

End Structure

<StructLayout(LayoutKind.Sequential, CharSet:=CharSet.Ansi)_

Private Structure DEVMODE

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCDEVICENAME)Public
dmDeviceName As String

Public dmSpecVersion As Short

Public dmDriverVersion As Short

Public dmSize As Short

Public dmDriverExtra As Short

Public dmFields As Integer

Public dmPosition As POINTL

Public dmDisplayOrientation As Integer

Public dmDisplayFixedOutput As Integer

Public dmColor As Short

Public dmDuplex As Short

Public dmYResolution As Short

Public dmTTOption As Short

Public dmCollate As Short

<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCFORMNAME)Public
dmFormName As String

Public dmLogPixels As Short

Public dmBitsPerPel As Integer

Public dmPelsWidth As Integer

Public dmPelsHeight As Integer

Public dmDisplayFlags As Integer

Public dmDisplayFrequency As Integer

End Structure

Private Declare Ansi Function ChangeDisplaySettingsEx Lib "user32" _

Alias "ChangeDisplaySettingsExA" _

(ByVal lpszDeviceName As String, _

ByRef lpDevMode As DEVMODE, _

ByVal hWnd As Integer, _

ByVal dwFlags As Integer, _

ByVal lParam As Integer) As Integer

Private Declare Ansi Function EnumDisplayDevices Lib "user32" _

Alias "EnumDisplayDevicesA" _

(ByVal lpDevice As Integer, _

ByVal iDevNum As Integer, _

ByRef lpDisplayDevice As DISPLAY_DEVICE, _

ByVal dwFlags As Integer) As Boolean

Private Declare Ansi Function EnumDisplaySettings Lib "user32" _

Alias "EnumDisplaySettingsA" _

(ByVal lpszDeviceName As String, _

ByVal iModeNum As Integer, _

ByRef pDevMode As DEVMODE) As Boolean

Sub Main()

Dim DD As DISPLAY_DEVICE

Dim DM As DEVMODE

Dim R As Boolean

Dim RR As Integer

DD.cb = Marshal.SizeOf(DD)

R = EnumDisplayDevices(0, 0, DD, 0)

DM.dmSize = Marshal.SizeOf(DM)

R = EnumDisplaySettings(DD.DeviceName, ENUM_CURRENT_SETTINGS, DM)

DM.dmDisplayOrientation = DMDO_180

DM.dmFields = DM_DISPLAYORIENTATION

RR = ChangeDisplaySettingsEx(DD.DeviceName, DM, 0, CDS_FORCE, 0)

End Sub

End Module


Jun 3 '07 #1
0 2015

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by steve | last post: by
1 post views Thread by Jay | last post: by
3 posts views Thread by byrd48 | last post: by
17 posts views Thread by santel_helvis | last post: by
reply views Thread by iwdu15 | last post: by
8 posts views Thread by lovecreatesbeauty | last post: by
10 posts views Thread by Joey_Stacks | last post: by
reply views Thread by Alexey Zalivin | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.