Hit-Parade .VB Research Center . Compteur
Accueil ~  Code ~  Programmes ~  Api ~  Forum ~  Cours ~  Livres ~  Quiz ~  Annuaire
~ Edito ~
12/03/2006 @ 13:39
Depuis la dernière mise à jour (qui remonte à... oulala plusieurs mois), un petit ménage de printemps s'impose. Ca tombe bien, c'est presque la période.
Au menu, et progressivement sur les jours à venir, rafraîchissement de plusieurs fonctions et procédures, nouvelles APIs et nouveaux programmes.

~ Rechercher ~

  

~ Annuaire VB ~
 Rechercher un site :
  

~ Partenaires ~

Procédure : ResolutionEcran
Changer la résolution (dimension) de l'écran.
(Consulté 19198 fois.)

' Déclaration des API
Public Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As Any) As Boolean
Public Declare Function
ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
Public Declare Function
SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long

' Déclaration des constantes
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
Public Const DM_WIDTH = &H80000
Public Const DM_HEIGHT = &H100000
Public Const WM_DEVMODECHANGE = &H1B
Public Const HWND_BROADCAST = &HFFFF&
Public Const HWND_DESKTOP = 0

' Déclaration du type utilisé
Public 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 Single, sgHeight As Single)
' Procédure de redimensionnement de l'écran
Dim blTMP As Boolean
Dim
lgTMP As Long
Dim
dmEcran As DEVMODE
lgTMP = 0
Do
 
  blTMP = EnumDisplaySettings(0, lgTMP, dmEcran)
  lgTMP = lgTMP + 1
Loop Until Not blTMP
dmEcran.dmFields = DM_WIDTH
Or DM_HEIGHT
' Affectation des novuelles dimensions
dmEcran.dmPelsWidth = sgWidth
dmEcran.dmPelsHeight = sgHeight
lgTMP = ChangeDisplaySettings(dmEcran, 0)
' Averti le système que la résolution a changé
Call SendMessage(HWND_BROADCAST, WM_DEVMODECHANGE, 0, 0)
End Sub

' Exemple d'appel de la procédure
Call ResolutionEcran( 1024, 768)

Visual Basic Research Center - (c) 2000/2002 -  Webmaster : docvb (chez) free (point) fr