Erdenmandal
03-18-2004, 05:50 AM
Hi, All
I want to change monitor setting. For example width, heigth, color und resolution.
Does somebody has Idea , how can I change it. I tried with Vb6. It works .But I have a problem with VB net to declare types.
Erdenmandal
03-18-2004, 07:24 AM
Hi,
in VB6
Public Const CCDEVICENAME As Long = 32
dmDeviceName As String * CCDEVICENAME
How can I declare it for Visual Basic NET ???
excaliber
03-18-2004, 07:26 PM
Might want to take a look here:
http://www.omniscium.com/index.asp?page=DotNetScreenResolution
Its in C#.Net, but you could try to translate it over (most of it is fairly self-explanatory and/or similar to VB.Net)
Erdenmandal
03-19-2004, 01:40 AM
Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Integer, ByVal iModeNum As Integer, ByRef lpDevMode As DevMode) As Boolean
Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (ByRef lpDevMode As DevMode, ByVal dwFlags As Integer) As Integer
Public Const INTERNET_CONNECTION_LAN As Long = &H2
Public Const INTERNET_CONNECTION_MODEM As Long = &H1
Public Const DIAL_UNATTENDED = &H8000
Public Const DIAL_FORCE_ONLINE = 1
Public Const DIAL_FORCE_UNATTENDED = 2
Public Const RAS95_MaxEntryName = 256
Public Const LOGPIXELSX As Long = 88
Public Const LOGPIXELSY As Long = 90
Public Const BITSPIXEL As Long = 12
Public Const HORZRES As Long = 8
Public Const VERTRES As Long = 10
Public Const VREFRESH As Long = 116
Public Const CCDEVICENAME As Long = 32
Public Const CCFORMNAME As Long = 32
Public Const DM_GRAYSCALE As Long = &H1
Public Const DM_INTERLACED As Long = &H2
Public Const DM_BITSPERPEL As Long = &H40000
Public Const DM_PELSWIDTH As Long = &H80000
Public Const DM_PELSHEIGHT As Long = &H100000
Public Const DM_DISPLAYFLAGS As Long = &H200000
Public Const DM_DISPLAYFREQUENCY As Long = &H400000
Public Const CDS_TEST = &H4
Structure DevMode
<VBFixedString(CCDEVICENAME), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropService s.UnmanagedType.ByValTStr, SizeConst:=CCDEVICENAME)> Public dmDeviceName As String
Dim dmSpecVersion As Short
Dim dmDriverVersion As Short
Dim dmSize As Short
Dim dmDriverExtra As Short
Dim dmFields As Integer
Dim dmOrientation As Short
Dim dmPaperSize As Short
Dim dmPaperLength As Short
Dim dmPaperWidth As Short
Dim dmScale As Short
Dim dmCopies As Short
Dim dmDefaultSource As Short
Dim dmPrintQuality As Short
Dim dmColor As Short
Dim dmDuplex As Short
Dim dmYResolution As Short
Dim dmTTOption As Short
Dim dmCollate As Short
<VBFixedString(CCFORMNAME), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropService s.UnmanagedType.ByValTStr, SizeConst:=CCFORMNAME)> Public dmFormName As String
Dim dmUnusedPadding As Short
Dim dmBitsPerPel As Short
Dim dmPelsWidth As Integer
Dim dmPelsHeight As Integer
Dim dmDisplayFlags As Integer
Dim dmDisplayFrequency As Integer
End Structure
'change display resolution
Sub Aufloesung_aendern_auf(ByVal Breite As Integer, ByVal Hoehe As Integer, ByVal Frequenz As Integer, ByRef Farbtiefe As Integer)
Dim DeveloperMode As DevMode
Dim retval As Integer
'UPGRADE_WARNING: Die Standardeigenschaft des Objekts DeveloperMode konnte nicht aufgelöst werden. Klicken Sie hier für weitere Informationen: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
EnumDisplaySettings(0, 0, DeveloperMode)
With DeveloperMode
.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_DISPLAYFREQUENCY Or DM_BITSPERPEL
.dmPelsWidth = Breite
.dmPelsHeight = Hoehe
.dmDisplayFrequency = Frequenz
.dmBitsPerPel = Farbtiefe
End With
'UPGRADE_WARNING: Die Standardeigenschaft des Objekts DeveloperMode konnte nicht aufgelöst werden. Klicken Sie hier für weitere Informationen: 'ms-help://MS.VSCC.2003/commoner/redir/redirect.htm?keyword="vbup1037"'
retval = ChangeDisplaySettings(DeveloperMode, CDS_TEST)
End Sub
In the Form
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Aufloesung_aendern_auf(TextBox1.Text, TextBox2.Text, TextBox3.Text, 32)
End Sub