VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



It's time to test a code which can change your display settings, which you usually do from the

by Ayan Chaudhuri (8 Submissions)
Category: Windows API Call/Explanation
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Tue 2nd April 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)

*** It's time to test a code which can change your display settings, which you usually do from the display properties of Windows-OS *** Try

API Declarations


'*** in DEVMODE declaration ***

' dmPanningWidth As Long
' dmPanningHeight As Long

Public Type DEVMODE
dmDeviceName As String * 32
dmSpecVersion As Integer
dmDriverVersion As Integer
dmSize As Integer
dmDriverExtra As Integer
dmFields As Long
dmOrientation As Integer
dmPaperSize As Integer
dmPaperLength As Integer
dmPaperWidth As Integer
dmScale As Integer
dmCopies As Integer
dmDefaultSource As Integer
dmPrintQuality As Integer
dmColor As Integer
dmDuplex As Integer
dmYResolution As Integer
dmTTOption As Integer
dmCollate As Integer
dmFormName As String * 32
dmUnusedPadding As Integer
dmBitsPerPixel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
dmICMMethod As Long
dmICMIntent As Long
dmMediaType As Long
dmDitherType As Long
dmReserved1 As Long
dmReserved2 As Long
End Type
Public Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As String, _
ByVal iModeNum As Long, lpDevMode As DEVMODE) As Long
Public Const ENUM_CURRENT_SETTINGS = -1
Public Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags _
As Long) As Long
Public Const CDS_UPDATEREGISTRY = &H1
Public Const CDS_TEST = &H2
Public Const DISP_CHANGE_SUCCESSFUL = 0
Public Const DISP_CHANGE_RESTART = 1


Rate It's time to test a code which can change your display settings, which you usually do from the



Dim dm As DEVMODE
Dim retval As Long

dm.dmSize = Len(dm)
retval = EnumDisplaySettings(vbNullString, ENUM_CURRENT_SETTINGS, dm)

dm.dmPelsWidth = Text1.Text  ' Width should be numeric (e.g. 800 or 640)
dm.dmPelsHeight = Text2.Text ' Height should be numeric (e.g. 600 or 480)

retval = ChangeDisplaySettings(dm, CDS_TEST)
If retval <> DISP_CHANGE_SUCCESSFUL Then
Debug.Print "Cannot change to that resolution!"
Else

retval = ChangeDisplaySettings(dm, CDS_UPDATEREGISTRY)
Select Case retval
Case DISP_CHANGE_SUCCESSFUL
Debug.Print "Resolution successfully changed!"
Case DISP_CHANGE_RESTART
Debug.Print "A reboot is necessary before the changes will take effect."
Case Else
Debug.Print "Unable to change resolution!"
End Select
End If
End Sub


Download this snippet    Add to My Saved Code

It's time to test a code which can change your display settings, which you usually do from the Comments

No comments have been posted about It's time to test a code which can change your display settings, which you usually do from the . Why not be the first to post a comment about It's time to test a code which can change your display settings, which you usually do from the .

Post your comment

Subject:
Message:
0/1000 characters