Тут должно быть про частоту: Option Explicit Const WM_DISPLAYCHANGE = &H7E Const HWND_BROADCAST = &HFFFF& Const EWX_LOGOFF = 0 Const EWX_SHUTDOWN = 1 Const EWX_REBOOT = 2 Const EWX_FORCE = 4 Const CCDEVICENAME = 32 Const CCFORMNAME = 32 Const DM_BITSPERPEL = &H40000 Const DM_PELSWIDTH = &H80000 Const DM_PELSHEIGHT = &H100000 Const DM_DISPLAYFREQUENCY = &H400000 Const CDS_UPDATEREGISTRY = &H1 Const CDS_TEST = &H4 Const DISP_CHANGE_SUCCESSFUL = 0 Const DISP_CHANGE_RESTART = 1 Const HORZRES = 8 Const VERTRES = 10 Const BITSPIXEL = 12 Const FREQUENCY = 116 Public 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 wid As Long Public hei As Long Public dep As Long Public fr As Long Public ofr As Long Declare Function GetDeviceCaps Lib "gdi32" (ByVal hDC As Long, ByVal nIndex As Long) As Long Declare Function GetDesktopWindow Lib "user32" () As Long Declare Function GetDC Lib "user32" (ByVal hwnd As Long) As Long Declare Function ReleaseDC Lib "user32" (ByVal hwnd As Long, ByVal hDC As Long) As Long 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 ExitWindowsEx Lib "user32" (ByVal uFlags As Long, ByVal dwReserved 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 Public Sub changeres(X As Long, Y As Long, Bits As Long, freq As Long) Dim DevM As DEVMODE, ScInfo As Long, erg As Long, an As VbMsgBoxResult 'Get the info into DevM erg = EnumDisplaySettings(0&, 0&, DevM) 'This is what we're going to change DevM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL Or DM_DISPLAYFREQUENCY DevM.dmPelsWidth = X 'ScreenWidth DevM.dmPelsHeight = Y 'ScreenHeight DevM.dmBitsPerPel = Bits '(can be 8, 16, 24, 32 or even 4) DevM.dmDisplayFrequency = freq ' Display frequency 'Now change the display and check if possible erg = ChangeDisplaySettings(DevM, CDS_TEST) 'Check if succesfull Select Case erg& Case DISP_CHANGE_RESTART an = MsgBox("Need restart", vbYesNo + vbSystemModal, "Info") If an = vbYes Then erg& = ExitWindowsEx(EWX_REBOOT, 0& End If Case DISP_CHANGE_SUCCESSFUL erg = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY) ScInfo = Y * 2 ^ 16 + X SendMessage HWND_BROADCAST, WM_DISPLAYCHANGE, ByVal Bits, ByVal ScInfo Case Else MsgBox "This mode doesn't support.", vbOKOnly + vbSystemModal, "Error" End Select End Sub
Public Sub GetVideoMode(ByRef Width As Long, ByRef Height As Long, ByRef Depth As Long, ByRef freq As Long) Dim hDC As Long hDC = GetDC(GetDesktopWindow()) Width = GetDeviceCaps(hDC, HORZRES) Height = GetDeviceCaps(hDC, VERTRES) Depth = GetDeviceCaps(hDC, BITSPIXEL) freq = GetDeviceCaps(hDC, FREQUENCY) ReleaseDC GetDesktopWindow(), hDC End Sub
'-------------------------------------- 'GetVideoMode - получить текущее разрешение, глубину цвета и частоту 'changeres - изменить
'использование: 'getvideomode w,h,d,f 'где w,h,d,f - заранее объявленные переменные типа long, в которые будут помещены значения текущей ширины, высоты, глубины цвета, частоты соответственно 'changeres x, y, Bits, freq 'x - высота; y - ширина 'Bits - глубина цвета; freq - частота 'пример:
dim w as long dim h as long dim d as long dim f as long getvideomode w,h,d,f changeres 1024, 768, 32, 85
Ответить
|