How To Change Screen Resolution ??? 
Author Message
 How To Change Screen Resolution ???

Hi,

How can I change the screen resolution On The Fly without restarting the
computer ???

Thanks in Advanced,
Goldman Asaf



Thu, 05 Oct 2000 03:00:00 GMT  
 How To Change Screen Resolution ???

Goldman:

Consider the following code fragments:

' Screen resolution at start up is retained here so that the
' monitor can be reset on exit.
Global OriginalxPixels As Long
Global OriginalyPixels As Long
Global ResetResolution As Boolean
Global Const SM_CXSCREEN = 0
Global Const SM_CYSCREEN = 1

Private Declare Function GetSystemMetrics _
  Lib "user32" _
  (ByVal nIndex As Long) _
  As Long
Private Declare Function EnumDisplaySettings _
  Lib "user32" Alias "EnumDisplaySettingsA" _
  (ByVal lpszDeviceName As Long, _
   ByVal iModeNum As Long, _
   lpDevMode As Any) _
  As Boolean

Private Declare Function ChangeDisplaySettings _
  Lib "user32" Alias "ChangeDisplaySettingsA" _
  (lpDevMode As Any, _
   ByVal dwFlags As Long) _
  As Long

Const CCHDEVICENAME = 32
Const CCHFORMNAME = 32
Type DEVMODE
  dmDeviceName As String * CCHDEVICENAME
  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 * CCHFORMNAME
  dmUnusedPadding As Integer
  dmBitsPerPel As Integer
  dmPelsWidth As Long
  dmPelsHeight As Long
  dmDisplayFlags As Long
  dmDisplayFrequency As Long
End Type

Dim DevM As DEVMODE

sub Form_Load()

' Get the screen settings.
  OriginalxPixels = GetSystemMetrics(SM_CXSCREEN)
  OriginalyPixels = GetSystemMetrics(SM_CYSCREEN)

' If the current resolution is not 1024x768, change the resolution
' to 1024x768 and signal the need to restore the resolution on exit.
  If OriginalxPixels <> 1024 Then
    ResetResolution = True
    Call SetResolution(1024, 768)
  Else
    ResetResolution = False
  End If

end sub

Sub SetResolution(ByVal mrWidth As Long, ByVal mrHeight As Long)
'
' Sets the monitor resolution to requested value.
'
Dim A As Boolean
Dim B As Long
Dim I As Long
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000

  I = 0
  Do
    A = EnumDisplaySettings(0&, I&, DevM)
    I = I + 1
  Loop Until Not A

  DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
  DevM.dmPelsWidth = mrWidth
  DevM.dmPelsHeight = mrHeight

  B = ChangeDisplaySettings(DevM, 0)
  If B <> 0 Then
    MsgBox "Video driver was unable to change resolution (" & Str(B) & ")",
vbOKOnly, "ChgRes"
    End
  End If

End Sub

End Sub

Quote:

> Hi,

> How can I change the screen resolution On The Fly without restarting the
> computer ???

> Thanks in Advanced,
> Goldman Asaf



Sun, 08 Oct 2000 03:00:00 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Screen coordinates change after changing screen resolution???

2. How to Change Screen Resolution in VBA

3. Acc 2.0 - Change screen resolution

4. How do I change Screen Resolutions?

5. How do you change screen resolution?

6. ****HELP**** Change screen resolution in VB3

7. having vb 5.0 change screen resolution and color depth

8. Q: Changing Screen Resolutions in VB

9. Help with logon script to change screen resolutions

10. How To Change Screen Resolution ???

11. ****HELP**** Change screen resolution in VB3

12. Checking & Changing Screen Resolution

 

 
Powered by phpBB® Forum Software