knakes | Pour la modifier, voilà un code : Code :
- DANS UN MODULE
- 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 SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
- Private Const CCHDEVICENAME = 32
- Private Const CCHFORMNAME = 32
- Private Const DM_WIDTH = &H80000
- Private Const DM_HEIGHT = &H100000
- Private Const WM_DEVMODECHANGE = &H1B
- Private Const HWND_BROADCAST = &HFFFF&
- Private Const HWND_DESKTOP = 0
- 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
- Dim dmEcran As DEVMODE
- Private Sub ResolutionEcran(sgWidth As Single, sgHeight As Single)
- Dim blTMP As Boolean
- Dim lgTMP As Long
- lgTMP = 0
- Do
- blTMP = EnumDisplaySettings(0, lgTMP, dmEcran)
- lgTMP = lgTMP + 1
- Loop Until Not blTMP
- dmEcran.dmFields = DM_WIDTH Or DM_HEIGHT
- dmEcran.dmPelsWidth = sgWidth
- dmEcran.dmPelsHeight = sgHeight
- lgTMP = ChangeDisplaySettings(dmEcran, 0)
- Call SendMessage(HWND_BROADCAST, WM_DEVMODECHANGE, 0, 0)
- End Sub
|
Pour appeler le changement de résolution : Code :
- Call ResolutionEcran(640, 480)
|
edit : Pour voir la résolution utilisée actuellement : Code :
- Largeur = Screen.Width / Screen.TwipsPerPixelX
- Hauteur = Screen.Height / Screen.TwipsPerPixelY
|
Voilà. Message édité par knakes le 07-04-2005 à 18:35:23
|