Configurar impresora

Hola de nuevo:
Necesito saber tomar el valor de la resolución de pantalla para compararla con lo que yo necesite, variarla y al finalizar la aplicación dejarlo tal como estaba.
¿Sabes cómo modificarla?
Gracias.

1 Respuesta

Respuesta
1
No es sencillo el cambio de resolución, pero te paso un método por API, copia esto en el procedimiento general del formulario:
Option Explicit
Private mResolucionCambiada As Boolean
Private mResAlto As Long
Private mResAncho As Long
Private mResBits As Long
Private DevM As DevMode
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwFlags As Long) As Long
Private Declare Function EnumDisplaySettings Lib "user32" Alias "EnumDisplaySettingsA" (ByVal lpszDeviceName As Long, ByVal iModeNum As Long, lpDevMode As DevMode) As Boolean
Const ENUM_CURRENT_SETTINGS As Long = -1&
Const ENUM_REGISTRY_SETTINGS As Long = -2&
Const CCHDEVICENAME = 32
Const CCHFORMNAME = 32
Const DM_BITSPERPEL = &H40000
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
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
Private Sub CambiarRes(ByVal Ancho As Long, ByVal Alto As Long, ByVal Colores As Long)
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL
DevM.dmSize = Len(DevM)
DevM.dmPelsWidth = Ancho
DevM.dmPelsHeight = Alto
DevM.dmBitsPerPel = Colores
Call ChangeDisplaySettings(DevM, 0)
End Sub
'ahora coloca esto en el Load del formulario:
mResolucionCambiada = False
DevM.dmSize = Len(DevM)
Call EnumDisplaySettings(0&, ENUM_CURRENT_SETTINGS, DevM)
mResAncho = DevM.dmPelsWidth
mResAlto = DevM.dmPelsHeight
mResBits = DevM.dmBitsPerPel
'en esas tres variables te quedara la resolucion actual de tu programa, esa la puedes comparar con la que requieres y para cambiarla escribes esto:
CambiarRes 800, 600, 16
Con eso lo cambias a 800X600 por 16Bit es colores, para restaurar a los valores anteriores solo tienes que colocar esto:
CambiarRes mResAncho, mResAlto, mResBits

Añade tu respuesta

Haz clic para o

Más respuestas relacionadas