1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76
| Option Explicit
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 Const CCHDEVICENAME = 32
Private Const CCHFORMNAME = 32
Private Const DM_WIDTH = &H80000
Private Const DM_HEIGHT = &H100000
'###########################
Private Const DM_BITSPERPEL = &H40000 ' Ajouté par l_autodidacte
'###########################
Private 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
Public Sub ResolutionEcran(sgWidth As Long, sgHeight As Long, Optional ByVal nBits& = 32)
' Optional ByVal nBits& = 32 : Paramètre ajouté par l_autodidacte
Dim blTMP As Boolean, lgTMP As Long, dmEcran As DEVMODE, res As Long
lgTMP = 0
Do
blTMP = EnumDisplaySettings(0, lgTMP, dmEcran)
lgTMP = lgTMP + 1
Loop While blTMP <> 0
dmEcran.dmFields = DM_WIDTH Or DM_HEIGHT Or DM_BITSPERPEL
' DM_BITSPERPEL : Ajouté par l_autodidacte
dmEcran.dmPelsWidth = sgWidth
dmEcran.dmPelsHeight = sgHeight
dmEcran.dmBitsPerPel = nBits
lgTMP = ChangeDisplaySettings(dmEcran, 0)
End Sub
Private Sub Command1_Click()
ResolutionEcran 800, 600, 16
End Sub
Private Sub Command2_Click()
ResolutionEcran 1024, 768 ', 32
End Sub
Private Sub Form_Load()
Command1.Caption = "Changer la résolution"
Command2.Caption = "Restaurer la résolution"
End Sub |
Partager