Resolution screen

1217meyrin Messages postés 159 Date d'inscription lundi 5 avril 2004 Statut Membre Dernière intervention 6 février 2007 - 24 janv. 2007 à 20:22
ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 - 31 janv. 2007 à 14:44
bonjour, j'ai ce code et quand je veux effectuer un changement de resolution comme suit, ca ne marche pas?SetResolution(800, 600, 32),

voici le code du module:

Private

Declare
Auto
Function EnumDisplaySettings
Lib "user32.dll" (
ByVal lpszDeviceName
As
String,
ByVal iModeNum
As Int32,
ByRef lpDevMode
As DEVMODE)
As
Boolean

Private
Declare
Auto
Function ChangeDisplaySettings
Lib "user32.dll" (
ByRef lpDevMode
As DEVMODE,
ByVal dwFlags
As Int32)
As Int32

Private
Const DM_BITSPERPEL
As Int32 = &H40000

Private
Const DM_PELSWIDTH
As Int32 = &H80000

Private
Const DM_PELSHEIGHT
As Int32 = &H100000

Private
Const DISP_CHANGE_SUCCESSFUL
As Int32 = 0 

Private
Structure POINTL

Public x
As Int32

Public y
As Int32

End
Structure 

Private
Structure DEVMODE_union1

' struct {

Public dmOrientation
As Int16

Public dmPaperSize
As Int16

Public dmPaperLength
As Int16

Public dmPaperWidth
As Int16

' }

Public dmPosition
As POINTL

End
Structure 

Private
Structure DEVMODE_union2

Public dmDisplayFlags
As Int32

Public dmNup
As Int32

End
Structure 

Private
Structure DEVMODE

Private
Const CCDEVICENAME
As Int32 = 32

Private
Const CCFORMNAME
As Int32 = 32 

Public dmDeviceName
As
String

Public dmSpecVersion
As Int16

Public dmDriverVersion
As Int16

Public dmSize
As Int16

Public dmDriverExtra
As Int16

Public dmFields
As Int32

Public u1
As DEVMODE_union1

Public dmScale
As Int16

Public dmCopies
As Int16

Public dmDefaultSource
As Int16

Public dmPrintQuality
As Int16

Public dmColor
As Int16

Public dmDuplex
As Int16

Public dmYResolution
As Int16

Public dmTTOption
As Int16

Public dmCollate
As Int16

Public dmFormName
As
String

Public dmUnusedPadding
As Int16

Public dmBitsPerPel
As Int16

Public dmPelsWidth
As Int32

Public dmPelsHeight
As Int32

Public u2
As DEVMODE_union2

Public dmDisplayFrequency
As Int32

Public dmICMMethod
As Int32

Public dmICMIntent
As Int32

Public dmMediaType
As Int32

Public dmDitherType
As Int32

Public dmReserved1
As Int32

Public dmReserved2
As Int32

Public dmPanningWidth
As Int32

Public dmPanningHeight
As Int32

End
Structure

Public
Function SetResolution(
ByVal Width
As Int32,
ByVal Height
As Int32,
ByVal BitsPerPixel
As Int16)
As
Boolean

Dim dm
As DEVMODE

If
Not EnumDisplaySettings(
Nothing, 0, dm)
Then

Return
False

Else

With dm.dmFields = DM_PELSWIDTH

Or DM_PELSHEIGHT
Or DM_BITSPERPEL.dmPelsWidth = Width

.dmPelsHeight = Height

.dmBitsPerPel = BitsPerPixel

End
With

Return (ChangeDisplaySettings(dm, 0) = DISP_CHANGE_SUCCESSFUL)

End
If

End
Function

1 réponse

ShareVB Messages postés 2676 Date d'inscription vendredi 28 juin 2002 Statut Membre Dernière intervention 13 janvier 2016 26
31 janv. 2007 à 14:44
0
Rejoignez-nous