so jetzt werde ich gleich voneuch erschlagen
ja ich weiß das das was gleich kommt quick and dirty ist eine mischung aus alt und etwas neuer und nicht ideal ist aber der feinschliff kommt zum schluss
hier mal mein Code bis jetzt
Private Declare Function EnumDisplaySettings Lib "user32" Alias _
"EnumDisplaySettingsA" (ByVal DeviceName As String, ByVal ModeNum As _
Integer, ByRef DevMode As DEVMODE) As Integer
Private Declare Function EnumDisplayDevices Lib "user32" Alias _
"EnumDisplayDevicesA" (ByVal lpDevice As String, ByVal iDevNum As UInteger, _
ByRef lpDisplayDevice As DISPLAY_DEVICE, ByVal dwFlags As UInteger) As _
Boolean
Private Declare Function ChangeDisplaySettings Lib "user32" Alias _
"ChangeDisplaySettingsA" (ByRef DEVMODE As DEVMODE, ByVal flags As Long) As _
Integer
' Private Declare Function ChangeDisplaySettingsEx Lib "user32" Alias
' "EnumDisplaySettingsExA" (ByVal lpszDeviceName As String, ByRef
' lpDeviceMode As DEVMODE, ByVal hwnd As IntPtr, ByVal dwFlags As UInteger,
' ByVal lParam As IntPtr) As DISP_CHANGE
<DllImport("user32.dll")> _
Private Shared Function ChangeDisplaySettingsEx(ByVal lpszDeviceName As _
String, ByRef lpDevMode As DEVMODE, ByVal hwnd As IntPtr, ByVal dwflags As _
UInteger, ByVal lParam As IntPtr) As DISP_CHANGE
End Function
'Wie soll passieren
Const ENUM_CURRENT_SETTINGS As Integer = -1
Const CDS_UPDATEREGISTRY As Integer = &H1
Const CDS_TEST As Long = &H2
Const CDS_FULLSCREEN = &H4
Const CDS_GLOBAL = &H4
Const CDS_SET_PRIMARY = &H10
Const CDS_RESET = &H40000000
Const CDS_NORESET = &H10000000
'Was soll übernommen werden zw gelesen im devmode struct
Private Const DM_BITSPERPEL = &H40000 'farbtiefe
Private Const DM_PELSWIDTH = &H80000 'breite
Private Const DM_PELSHEIGHT = &H100000 'höhe
Private Const DM_DISPLAYFREQUENCY = &H400000 'herz
Private Const DM_DISPLAYFLAGS = &H200000 'Grafikarteneigenschaften
Private Const DM_GRAYSCALE = 1 'Geräte üterstützt keine arben nur Grau
' schwarz weiß
Private Const DM_INTERLACED = 2 'Gerät unterstützt Farben
'rückgabe Werte der Funktion ChangeDisplaySettings
Const DISP_CHANGE_SUCCESSFUL As Integer = 0
Const DISP_CHANGE_RESTART As Integer = 1
Const DISP_CHANGE_FAILED As Integer = -1
'DEVMODE Struct
Const CCDEVICENAME As Integer = 32
Const CCFORMNAME As Integer = 32
Public Structure POINTL
Public x As Integer
Public y As Integer
End Structure
<StructLayout(LayoutKind.Sequential)> _
Public Structure DEVMODE
Public Const CCHDEVICENAME As Integer = 32
Public Const CCHFORMNAME As Integer = 32
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCHDEVICENAME)> _
Public dmDeviceName As String
Public dmSpecVersion As Short
Public dmDriverVersion As Short
Public dmSize As Short
Public dmDriverExtra As Short
Public dmFields As DM
Public dmOrientation As Short
Public dmPaperSize As Short
Public dmPaperLength As Short
Public dmPaperWidth As Short
Public dmScale As Short
Public dmCopies As Short
Public dmDefaultSource As Short
Public dmPrintQuality As Short
Public dmColor As Short
Public dmDuplex As Short
Public dmYResolution As Short
Public dmTTOption As Short
Public dmCollate As Short
<MarshalAs(UnmanagedType.ByValTStr, SizeConst:=CCHFORMNAME)> _
Public dmFormName As String
Public dmLogPixels As Short
Public dmBitsPerPel As Integer ' Declared wrong in the full framework
Public dmPelsWidth As Integer
Public dmPelsHeight As Integer
Public dmDisplayFlags As Integer
Public dmDisplayFrequency As Integer
Public dmICMMethod As Integer
Public dmICMIntent As Integer
Public dmMediaType As Integer
Public dmDitherType As Integer
Public dmReserved1 As Integer
Public dmReserved2 As Integer
Public dmPanningWidth As Integer
Public dmPanningHeight As Integer
Public dmPositionX As Integer ' Using a PointL Struct does not work
Public dmPositionY As Integer
Public dmPosition As pointl
End Structure |