Visualizzazione dei risultati da 1 a 8 su 8

Discussione: risoluzione schermo

  1. #1

    risoluzione schermo

    Come si fa per impostare la risoluzione dello schermo da visual basic durante l'esecuzione di un programma, facendo si che alla chiusura la risoluzione torni originale???

  2. #2
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    327
    Scusa se rispondo con una domanda.

    Come mai ti serve questo artefizio? Che problemi ci sono? Magari si possono risolvere in altro modo.

  3. #3
    perchè devo fare un programma a tutto schermo ed è fatto per la risoluzione 800x600
    e se un pc ha un altra risoluzione voglio che imposti 800x600 durante l'esecuzione...capito??

  4. #4
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    327
    questo si può fare gestendo l'evento form_resize
    la puoi spostare tutti gli oggetti del form in base alla risoluzione dello scermo.

    Per ogni oggetto ci sono le proprietà:

    left : quanti twips dista dalla sinistra del form o frame

    top: quanti twips dista dall'alto del form/frame

    height: l'altezza dell'oggetto

    width: la larghezza dell'oggetto.

    es:

    hai un form con un frame dentro e vuoi che il frame sia largo quanto il form:

    frame1.top=0
    frame1.left=0
    frame1.width=form1.ScaleWidth
    frame1.height=form1.ScaleHeight

  5. #5
    Utente di HTML.it L'avatar di biste
    Registrato dal
    Apr 2001
    Messaggi
    877
    codice:
    Option Explicit
    Const WM_DISPLAYCHANGE = &H7E
    Const HWND_BROADCAST = &HFFFF&
    Const EWX_LOGOFF = 0
    Const EWX_SHUTDOWN = 1
    Const EWX_REBOOT = 2
    Const EWX_FORCE = 4
    Const CCDEVICENAME = 32
    Const CCFORMNAME = 32
    Const DM_BITSPERPEL = &H40000
    Const DM_PELSWIDTH = &H80000
    Const DM_PELSHEIGHT = &H100000
    Const CDS_UPDATEREGISTRY = &H1
    Const CDS_TEST = &H4
    Const DISP_CHANGE_SUCCESSFUL = 0
    Const DISP_CHANGE_RESTART = 1
    Const BITSPIXEL = 12
    Private 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
    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
    Private Declare Function ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved As Long) As Long
    Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
    Private Declare Function CreateDC Lib "gdi32" Alias "CreateDCA" (ByVal lpDriverName As String, ByVal lpDeviceName As String, ByVal lpOutput As String, ByVal lpInitData As Any) As Long
    Private Declare Function DeleteDC Lib "gdi32" (ByVal hdc As Long) As Long
    Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
    Dim OldX As Long, OldY As Long, nDC As Long
    Sub ChangeRes(X As Long, Y As Long, Bits As Long)
        Dim DevM As DEVMODE, ScInfo As Long, erg As Long, an As VbMsgBoxResult
        'Get the info into DevM
        erg = EnumDisplaySettings(0&, 0&, DevM)
        'This is what we're going to change
        DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL
        DevM.dmPelsWidth = X 'ScreenWidth
        DevM.dmPelsHeight = Y 'ScreenHeight
        DevM.dmBitsPerPel = Bits '(can be 8, 16, 24, 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)
                ScInfo = Y * 2 ^ 16 + X
                'Notify all the windows of the screen resolution change
                SendMessage HWND_BROADCAST, WM_DISPLAYCHANGE, ByVal Bits, ByVal ScInfo
                MsgBox "Everything's ok", vbOKOnly + vbSystemModal, "It worked!"
            Case Else
                MsgBox "Mode not supported", vbOKOnly + vbSystemModal, "Error"
        End Select
    End Sub
    Private Sub Form_Load()
        'KPD-Team 1999
        'URL: http://www.allapi.net/
        'E-Mail: KPDTeam@Allapi.net
        Dim nDC As Long
        'retrieve the screen's resolution
        OldX = Screen.Width / Screen.TwipsPerPixelX
        OldY = Screen.Height / Screen.TwipsPerPixelY
        'Create a device context, compatible with the screen
        nDC = CreateDC("DISPLAY", vbNullString, vbNullString, ByVal 0&)
        'Change the screen's resolution
        ChangeRes 640, 480, GetDeviceCaps(nDC, BITSPIXEL)
    End Sub
    Private Sub Form_Unload(Cancel As Integer)
        'restore the screen resolution
        ChangeRes OldX, OldY, GetDeviceCaps(nDC, BITSPIXEL)
        'delete our device context
        DeleteDC nDC
    End Sub
    HTH
    UGIdotNET
    Microsoft .NET MCAD
    C++, C#, VB6, VB.NET, ASP, ASP.NET
    SQL Server 2000

  6. #6
    Utente di HTML.it
    Registrato dal
    Oct 2002
    Messaggi
    327
    e se uno si è disposto per bene le icone, ben distribuite sul desktop sfruttando la ris 1024x768 che casino succede cambiando la risoluzione?
    Non è questo il metodo...

  7. #7
    per ovviare si potrebbe impostare il codice in modo che non appena si torna alla risoluzione originale si dispongano automaticamente le icone, no? visto che il progetto è poi di tipo "semi-professionale" e da visualizzare su video proiettore non penso che interessi la disposizione in un modo particolare, potrebbe andar bene quella automatica...che ne dite???

  8. #8
    io ho trovato in rete una ocx free che fa il resize.
    adatta i controlli del form in base alla risoluzione, unico problema il testo resta nella dimensione originale, e son le varie risoluzioni crea un pò di casino.

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.