Страница: 1 | 2 |
|
Вопрос: Смена разрешения экрана
|
Добавлено: 27.11.05 17:57
|
|
Номер ответа: 18 Автор ответа: Страшный Сон
Вопросов: 46 Ответов: 848
|
Профиль | | #18
|
Добавлено: 02.12.05 10:21
|
Daleko ne haker: да нельзя по идее. Все приложения должны быть завершаемы.
Tamplier: создай такой модуль:
Attribute VB_Name = "AdvScrResolution"
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
Private Declare Function GetDeviceCaps Lib "gdi32" ( ByVal hDC As Long, ByVal nIndex As Long) As Long
Private Declare Function GetDesktopWindow Lib "user32" () As Long
Private Declare Function GetDC Lib "user32" ( ByVal hWnd As Long) As Long
Private Declare Function ReleaseDC Lib "user32" ( ByVal hWnd As Long, ByVal hDC As Long) As Long
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
Private Declare Function ExitWindowsEx Lib "user32" ( ByVal uFlags As Long, ByVal dwReserved As Long) As Long
'Private 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 Function SetVideoMode( ByVal X As Long, ByVal Y As Long, ByVal Bits As Long, ByVal freq As Long) 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
  evM.dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL Or DM_DISPLAYFREQUENCY
  evM.dmPelsWidth = X 'ScreenWidth
  evM.dmPelsHeight = Y 'ScreenHeight
  evM.dmBitsPerPel = Bits '(can be 8, 16, 24, 32 or even 4)
  evM.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("Для применения видео режима нужна перезагрузка.", vbExclamation + vbYesNo + vbSystemModal, "Информация"
'If an = vbYes Then
'erg = ExitWindowsEx(EWX_REBOOT, 0&
erg = ChangeDisplaySettings(DevM, CDS_UPDATEREGISTRY)
ScInfo = Y * 2 ^ 16 + X
SendMessage HWND_BROADCAST, WM_DISPLAYCHANGE, ByVal Bits, ByVal ScInfo
SetVideoMode = 1
'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
SetVideoMode = 1
Case Else
'MsgBox "Видео режим не поддерживается.", vbCritical + vbOKOnly + vbSystemModal, "Ошибка"
SetVideoMode = 0
End Select
End Function
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)
  epth = GetDeviceCaps(hDC, BITSPIXEL)
freq = GetDeviceCaps(hDC, FREQUENCY)
ReleaseDC GetDesktopWindow(), hDC
End Sub
'--------------------------------------
'GetVideoMode - получить текущее разрешение, глубину цвета и частоту
'ChangeRes - изменить
'использование: ChangeRes x, y, Bits, freq
'x - высота; y - ширина
'Bits - глубина цвета; freq - частота
'пример:
'ChangeRes 1024, 768, 32, 85
Ответить
|
Номер ответа: 22 Автор ответа: Kostik
Вопросов: 6 Ответов: 27
|
Профиль | | #22
|
Добавлено: 08.03.06 21:11
|
Определение разрешения и количества цветов дисплея
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 Const HORZRES = 8
Public Const VERTRES = 10
Public Const BITSPIXEL = 12
Public Sub GetVideoMode(ByRef Width As Long, ByRef Height As Long, ByRef Depth As Long)
 im hDC As Long
hDC = GetDC(GetDesktopWindow())
Width = GetDeviceCaps(hDC, HORZRES)
Height = GetDeviceCaps(hDC, VERTRES)
 epth = GetDeviceCaps(hDC, BITSPIXEL)
ReleaseDC GetDesktopWindow(), hDC
End Sub
Как изменить текущее разрешение экрана
Public Const DM_BITSPERPEL = &H40000
Public Const DM_PELSWIDTH = &H80000
Public Const DM_PELSHEIGHT = &H100000
Public Const CCHDEVICENAME = 32
Public Const CCHFORMNAME = 32
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
Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" (lpDevMode As DEVMODE,
ByVal dwFalgs As Long) As Long
Public Sub SetVideoMode(Width As Long, height As Long, Depth As Long)
 im dm As DEVMODE
dm.dmPelsWidth = Width
dm.dmPelsHeight = height
dm.dmBitsPerPel = Depth
dm.dmSize = Len(dm)
dm.dmFields = DM_PELSWIDTH + DM_PELSHEIGHT + DM_BITSPERPEL
ChangeDisplaySettings dm, 0
End Sub
Ответить
|
Страница: 1 | 2 |
Поиск по форуму