- Код: Выделить всё
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
Const CCDEVICENAME = 32
Const CCFORMNAME = 32
Const DM_PELSWIDTH = &H80000
Const DM_PELSHEIGHT = &H100000
Public OldScreenWidth As Long, OldScreenHeight As Long
Private Type DEVMODE
dmDeviceName As String * CCDEVICENAME
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 * CCFORMNAME
dmUnusedPadding As Integer
dmBitsPerPel As Integer
dmPelsWidth As Long
dmPelsHeight As Long
dmDisplayFlags As Long
dmDisplayFrequency As Long
End Type
Public Sub GetVideoMode(ByRef Width As Long, ByRef Height As Long, ByRef Depth As Long)
Dim hDC As Long
hDC = GetDC(GetDesktopWindow())
Width = GetDeviceCaps(hDC, HORZRES)
Height = GetDeviceCaps(hDC, VERTRES)
Depth = GetDeviceCaps(hDC, BITSPIXEL)
ReleaseDC GetDesktopWindow(), hDC
End Sub
Sub ChangeRes(iWidth As Long, iHeight As Long)
Dim a As Boolean
Dim i&
i = 0
Do
a = EnumDisplaySettings(0&, i&, DevM)
i = i + 1
Loop Until (a = False)
Dim b&
DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT
DevM.dmPelsWidth = iWidth
DevM.dmPelsHeight = iHeight
b = ChangeDisplaySettings(DevM, 0)
End Sub
Sub DetectResolution(NeedWidth As Long, NeedHeight As Long)
Dim Height As Long, Width As Long, Depth As Long, NewDepth As String
GetVideoMode Width, Height, Depth
OldScreenWidth = Width
OldScreenHeight = Height
If Width <> NeedWidth And Height <> NeedHeight Then
ChangeRes NeedWidth, NeedHeight
End If
End Sub
Так вот. В начале проги я поставил "ChangeRes 800,600", а в конце
"ChangeRes OldScreenWidth, OldScreenHeight". И почему-то при выходе и проги частота обновления экрана устанавливается на 60 Гц . С чего бы это? Может из-за XP-шки?