Visualizzazione dei risultati da 1 a 3 su 3
  1. #1

    Cambiare la risoluzione in visualbasic

    Come si può fare in visualbaisc che premendo un pullsante cambia la risoluzione. Facciamo premendo cambia la risoluzione a 800X600.

    Forse mi potete dire anche questo.

    Se io tengo la risoluzione a 800X600 il pulsante command1 deve con enabled false.
    Chiamatemi sven se volete non ho voglia di fare una nuova email per una nuova registrazione xD
    Mac Future User , Ventilatore for PC Cooler user , - dry is coming -

  2. #2
    Utente di HTML.it
    Registrato dal
    Jun 2007
    Messaggi
    53
    Ciao.
    codice:
    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
    Public Function CheckRez(pixelWidth As Long, pixelHeight As Long) As Boolean
        '
        Dim lngTwipsX As Long
        Dim lngTwipsY As Long
        '
        ' converte i pixels in twips
        lngTwipsX = pixelWidth * 15
        lngTwipsY = pixelHeight * 15
        '
        ' rileva la risoluzione corrente
        If lngTwipsX <> Screen.Width Then
            CheckRez = False
        Else
            If lngTwipsY <> Screen.Height Then
                CheckRez = False
            Else
                CheckRez = True
            End If
        End If
        '
    End Function
    
    Public Sub ChangeVideoResOut(mWidth As Long, mHeight As Long)
    'Changes the resolution to 640x480 with the current colordepth.
    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 = mWidth 'ScreenWidth
    DevM.dmPelsHeight = mHeight '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)
        Case Else
            MsgBox "Modalità video non supportata.", vbOKOnly + vbSystemModal, "Fa.Ge.Ma. 2003"
    End Select
    End Sub
    
    
    Public Sub ChangeVideoResIn()
    'Changes the resolution to 640x480 with the current colordepth.
    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 = 1024 'ScreenWidth
    DevM.dmPelsHeight = 768 '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)
        Case Else
            MsgBox "Modalità video non supportata.", vbOKOnly + vbSystemModal, "Fa.Ge.Ma. 2003"
    End Select
    End Sub
    Usa CheckRez per testare la risoluzionecorrente, usa ChangeVideoResIn per modificare la risoluzione se quella corrente non va bene, usa ChangeVideoResOut per ripristinare la vecchia risoluzione quando esci del tuo prog.
    Ciao.

  3. #3
    Grazie
    Chiamatemi sven se volete non ho voglia di fare una nuova email per una nuova registrazione xD
    Mac Future User , Ventilatore for PC Cooler user , - dry is coming -

Permessi di invio

  • Non puoi inserire discussioni
  • Non puoi inserire repliche
  • Non puoi inserire allegati
  • Non puoi modificare i tuoi messaggi
  •  
Powered by vBulletin® Version 4.2.1
Copyright © 2025 vBulletin Solutions, Inc. All rights reserved.