Results 1 to 8 of 8

Thread: simply changing the screen reselution

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    I currently have this in a model:

    Code:
    Option Explicit
    
    Private Declare Function GetSystemMetrics Lib "user32" (ByVal nIndex As Long) As Long
    
    Private Const SM_CXSCREEN = 0
    Private Const SM_CYSCREEN = 1
    
    ' Check whether screen resolution is set to 640x480
    ' Returns True if the resolution is at 640x480 else
    ' False is returned
    Public Function GetScreenResolution640x480() As Boolean
    Dim lTemp As String
    ' Temporary string to hold returned screen
    ' resolution
    lTemp = GetSystemMetrics(SM_CXSCREEN) & "x" & GetSystemMetrics(SM_CYSCREEN)
    ' Call the API function twice to return
    ' screen size for each axis as format into
    ' the temporary string
    If lTemp = "640x480" Then
      ' Check whether resolution is set to 640x480
      GetScreenResolution640x480 = True
      ' True
    Else
      GetScreenResolution640x480 = False
      ' False
    End If
    End Function


    and in the form load it says:

    Code:
    If GetScreenResolution640x480 = True Then
    end
    End If


    now is there a simple command that changes there screen to 800 X 600

    or do I have to use what I downloaded from vb world

    thanks in advance
    NXSupport - Your one-stop source for computer help

  2. #2
    Guest
    The above code does not change the resolution, rather, it check what it is. See this tip for information on changing the resolution.

    If your question was, 'How can I check if it's 800x600', you can simply change If lTemp = "640x480" Then to If lTemp = "800x600" Then.



  3. #3

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    when I try that tip it doesn't work
    I got errors in the Basic Module

    and my code just checks to see if its 600x800 thats all it doesn't change the reselution


    any other ideas?
    NXSupport - Your one-stop source for computer help

  4. #4
    Guest
    Author may have messed up a little. I have modified the code so it will work.

    Put this in a Module
    Code:
    Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
    Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
    Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    Public Const EWX_LOGOFF = 0
    Public Const EWX_SHUTDOWN = 1
    Public Const EWX_REBOOT = 2
    Public Const EWX_FORCE = 4
    Public Const CCDEVICENAME = 32
    Public Const CCFORMNAME = 32
    Public Const DM_BITSPERPEL = &H40000
    Public Const DM_PELSWIDTH = &H80000
    Public Const DM_PELSHEIGHT = &H100000
    Public Const CDS_UPDATEREGISTRY = &H1
    Public Const CDS_TEST = &H4
    Public Const DISP_CHANGE_SUCCESSFUL = 0
    Public Const DISP_CHANGE_RESTART = 1
    Type DEVMODE
        dmDeviceName As String * CCDEVICENAME
        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 * CCFORMNAME
        dmUnusedPadding As Integer
        dmBitsPerPel As Integer
        dmPelsWidth As Long
        dmPelsHeight As Long
        dmDisplayFlags As Long
        dmDisplayFrequency As Long
    End Type
    Put this in a CommandButton

    Code:
    Private Sub Command1_Click()
    
        Dim DevM As DEVMODE
        'Get the info into DevM
        erg& = EnumDisplaySettings(0&, 0&, DevM)
        'We don't change the colordepth, because a
        'rebot will be necessary
        
        DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT 'Or DM_BITSPERPEL
        DevM.dmPelsWidth = 640 'ScreenWidth
        DevM.dmPelsHeight = 480 'ScreenHeight
        DevM.dmBitsPerPel = 32 '(could be 8, 16, 32 or even 4)
        
        'Now change the display and check if possible
        
        erg& = ChangeDisplaySettings(DevM, CDS_TEST)
        
        'Check if succesfull
        Select Case erg&
        Case DISP_CHANGE_RESTART
            an = MsgBox("You've to reboot", vbYesNo + vbSystemModal, "Info")
            If an = vbYes Then
                erg& = ExitWindowsEx(EWX_REBOOT, 0&)
            End If
        Case DISP_CHANGE_SUCCESSFUL
            erg& = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
            MsgBox "Everything's ok", vbOKOnly + vbSystemModal, "It worked!"
        Case Else
            MsgBox "Mode not supported", vbOKOnly + vbSystemModal, "Error"
        End Select
        
    End Sub

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    thanks megatron
    NXSupport - Your one-stop source for computer help

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    when I run the program with my screen size as 640 x 480
    an error allways comes up at
    erg&
    NXSupport - Your one-stop source for computer help

  7. #7
    Guest
    You can change the Width and Height by modifing these lines.

    Code:
    DevM.dmPelsWidth = 640 'ScreenWidth
    DevM.dmPelsHeight = 480 'ScreenHeight
    What is the description of your Error?

  8. #8

    Thread Starter
    Frenzied Member
    Join Date
    Jun 2000
    Location
    East Providence, RI
    Posts
    1,715
    yea I know, I did edit that, I changed it to 800 * 600


    then I put my monitors reselution to 640 * 480

    then an error came up

    and when I click DebUG the it highlights erg&
    then it says varaible not defined
    NXSupport - Your one-stop source for computer help

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width