Modifier la résolution de plusieurs écrans

Résolu
Signaler
Messages postés
22
Date d'inscription
samedi 22 janvier 2005
Statut
Membre
Dernière intervention
10 octobre 2010
-
Messages postés
22
Date d'inscription
samedi 22 janvier 2005
Statut
Membre
Dernière intervention
10 octobre 2010
-
Bonjour,

J'ai récupérer le code suivant sur le site pour modifier la résolution d'un écran, mais comment l'adapter pour modifier l'affichage de 4 écrans que j'utilise pour mon application.

Merci !


<ol>
<li>
</li>
<li>
Option

Explicit

</li>
<li>
</li>
<li>
</li>
<li>
Const
CCHDEVICENAME = 32
</li>
<li>
Const
CCHFORMNAME = 32
</li>
<li>
</li>
<li>
Private

Type
DEVMODE
</li>
<li>    dmDeviceName As
String
* CCHDEVICENAME
</li>
<li>    dmSpecVersion As Integer
</li>
<li>    dmDriverVersion As Integer
</li>
<li>    dmSize As Integer
</li>
<li>    dmDriverExtra As Integer
</li>
<li>    dmFields As Long
</li>
<li>    dmOrientation As Integer
</li>
<li>    dmPaperSize As Integer
</li>
<li>    dmPaperLength As Integer
</li>
<li>    dmPaperWidth As Integer
</li>
<li>    dmScale As Integer
</li>
<li>    dmCopies As Integer
</li>
<li>    dmDefaultSource As Integer
</li>
<li>    dmPrintQuality As Integer
</li>
<li>    dmColor As Integer
</li>
<li>    dmDuplex As Integer
</li>
<li>    dmYResolution As Integer
</li>
<li>    dmTTOption As Integer
</li>
<li>    dmCollate As Integer
</li>
<li>    dmFormName As
String
* CCHFORMNAME
</li>
<li>    dmUnusedPadding As Integer
</li>
<li>    dmBitsPerPel As Integer
</li>
<li>    dmPelsWidth As Long
</li>
<li>    dmPelsHeight As Long
</li>
<li>    dmDisplayFlags As Long
</li>
<li>    dmDisplayFrequency As Long
</li>
<li>
End

Type

</li>
<li>
</li>
<li>
Const
DM_BITSPERPEL = &H40000
</li>
<li>
Const
DM_PELSWIDTH = &H80000
</li>
<li>
Const
DM_PELSHEIGHT = &H100000
</li>
<li>
Const
DM_DISPLAYFLAGS = &H200000
</li>
<li>
Const
DM_DISPLAYFREQUENCY = &H400000
</li>
<li>
</li>
<li>
Private

Declare

Function
ChangeDisplaySettings Lib <var>"user32"</var> Alias
</li>
<li>
<var>"ChangeDisplaySettingsA"</var> (lpInitData As DEVMODE, ByVal dwFlags As Long)
</li>
<li>As Long
</li>
<li>
Private

Declare

Function
EnumDisplaySettings Lib <var>"user32"</var> Alias
</li>
<li>
<var>"EnumDisplaySettingsA"</var> (lpszDeviceName As Any, ByVal iModeNum As Long,
</li>
<li>lpDevMode As Any) As Boolean
</li>
<li>
Private

Declare

Function
ExitWindowsEx Lib <var>"user32"</var> (ByVal uFlags As
</li>
<li>Long, ByVal dwReserved As Long) As Long
</li>
<li>
Private

Declare

Function
GetDeviceCaps Lib <var>"gdi32"</var> (ByVal hdc As Long,
</li>
<li>ByVal nIndex As Long) As Long
</li>
<li>
Const
BITSPIXEL = 12
</li>
<li>
Dim
D As DEVMODE
</li>
<li>
dim
lBits As Long, Largeurecran As Double, Hauteurecran As Double
</li>
<li>
</li>
<li>
</li>
<li>
<samp>'*************écrire ce code dans "Form_Activate"**************</samp>
</li>
<li>
</li>
<li>
Private

Sub
Form_Activate()
</li>
<li>
</li>
<li>    lBits = GetDeviceCaps(hdc, BITSPIXEL)
</li>
<li>    Largeur = Screen.
Width
\ Screen.TwipsPerPixelX
</li>
<li>    Hauteur = Screen.Height \ Screen.TwipsPerPixelY
</li>
<li>   
Call
EnumDisplaySettings(0&, -1, D)
</li>
<li>   D.dmFields = DM_BITSPERPEL Or DM_PELSWIDTH Or DM_PELSHEIGHT
</li>
<li>   D.dmPelsWidth = 1024 <samp>'vous pouvez spécifier la résolution désirée</samp></li>
<li>   D.dmPelsHeight = 768 <samp>'vous pouvez spécifier la résolution désirée</samp></li>
<li>   D.dmBitsPerPel = 32
</li>
<li>   
Call
ChangeDisplaySettings(D, 1)
</li>
<li>    
</li>
<li>
End

Sub

</li>
<li>
</li>
<li>
<samp>'********écrire ce code dans "Form_Terminate"***********************</samp>
</li>
<li>
</li>
<li>
Private

Sub
Form_Terminate()
</li>
<li>
Dim
res As DEVMODE
</li>
<li> 
Call
EnumDisplaySettings(0&, -1, res)
</li>
<li>   res.dmFields = DM_BITSPERPEL Or DM_PELSWIDTH Or DM_PELSHEIGHT
</li>
<li>   res.dmPelsWidth = Largeur
</li>
<li>   res.dmPelsHeight = Hauteur
</li>
<li>   res.dmBitsPerPel = lBits
</li>
<li>   
Call
ChangeDisplaySettings(res, 1)
</li>
<li>    
</li>
<li>
End

Sub

</li>
</ol>

1 réponse

Messages postés
22
Date d'inscription
samedi 22 janvier 2005
Statut
Membre
Dernière intervention
10 octobre 2010

On est jamais mieux servi que par soi-méme

Une Soixantaine d'internautes est venu lire mon problème et personne n'a su y répondre???

Bref moi j'ai cherché et j'ai écris ça.

Ca marche pour moi.

Je vous le transmets au cas où ça interesserait quelqu'un

'------------------------------------------------------
Option Explicit


Private Declare Function ChangeDisplaySettingsEx Lib "user32" Alias "ChangeDisplaySettingsExA" (lpszDeviceName As Any, lpDevMode As Any, ByVal hWnd As Long, ByVal dwFlags As Long, lParam As Any) As Long


Private Type DEVMODE
    dmDeviceName As String * 32
    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 * 32
    dmUnusedPadding As Integer
    dmBitsPerPel As Integer
    dmPelsWidth As Long
    dmPelsHeight As Long
    dmDisplayFlags As Long
    dmDisplayFrequency As Long
    dmICMMethod As Long 'NT 4.0
End Type


Dim NRame As Byte
Dim DLL_COS As Object
Dim Machine(2) As Object
Dim Wagon(8) As Object
Dim Rame2Côtés As Object
Dim Câblot As Object
Dim Côté As String


Private Sub Main()
Dim J As Byte


' *********************************************************************************
' Ces lignes pour modifier la résolution vidéo
Dim DevM As DEVMODE
DevM.dmSize = Len(DevM)
DevM.dmFields = &H80000 Or &H100000
DevM.dmPelsWidth = 1280
DevM.dmPelsHeight = 1024


Call ChangeDisplaySettingsEx(ByVal "[file://\\.\DISPLAY1 \\.\DISPLAY1]", DevM, ByVal 0&, &H4, ByVal 0&)
Call ChangeDisplaySettingsEx(ByVal "[file://\\.\DISPLAY2 \\.\DISPLAY2]", DevM, ByVal 0&, &H4, ByVal 0&)
Call ChangeDisplaySettingsEx(ByVal "[file://\\.\DISPLAY3 \\.\DISPLAY3]", DevM, ByVal 0&, &H4, ByVal 0&)
Call ChangeDisplaySettingsEx(ByVal "[file://\\.\DISPLAY4 \\.\DISPLAY4]", DevM, ByVal 0&, &H4, ByVal 0&)
' *********************************************************************************