473,404 Members | 2,137 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,404 software developers and data experts.

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 2198

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Apostolis K. | last post by:
I include an AdRotator component but the component doesn't rotate the ads _index.asp_ <% Set objAd=Server.CreateObject("MSWC.AdRotator") vAdRotation=objAd.GetAdvertisement("ads.txt") ...
3
by: steve | last post by:
I have a tablet PC and I write a application on this tablet PC, I would like to rotate the screen from portrait<->landscape mode(or 90/180/270 degree), what should I do? I only find the code for...
1
by: Jay | last post by:
I'm wondering if anyone has even encountered a control or other scripting that will automatically rotate the rows of a datagrid... I am in the process of building an asp.net application that will...
3
by: byrd48 | last post by:
Hi, I am developing a web site which allows users to upload and share photos. I have a datalist which lists the photos and has the usual edit, update commands. Within the edititemtemplate, I...
17
by: santel_helvis | last post by:
Hi All, Could anyone tell me how to rotate the image in javascript. Which concepts I should concentrate to rotate the image
0
by: iwdu15 | last post by:
hi, im drawing about 6 GDI drawn objects on the screen. How can i make each one rotate individually in different directions, speeds, etc? ive looked everywhere and cant seem to figure it out --...
8
by: lovecreatesbeauty | last post by:
I write a function to rotate a matrix by 90 degrees clockwise, this function works on a matrix of specific size, for example, it rotates a 4*4 matrix of integers in the following code. The function...
10
by: Joey_Stacks | last post by:
Does anyone know of a scipt that will rotate random div layers on page refresh? I have a primary content area front and center on my site homepage, and I'd like to rotate various chunks of html...
0
by: Alexey Zalivin | last post by:
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....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.