一个VB问题 15

如何用VB制作一个快速切换分辨率的程序只要在1024×7681280×800和800×600之间切换... 如何用VB制作一个快速切换分辨率的程序
只要在1024×768 1280×800 和 800×600之间切换
展开
 我来答
Finding___
2008-11-30 · TA获得超过2万个赞
知道大有可为答主
回答量:7100
采纳率:0%
帮助的人:4408万
展开全部
Option Explicit

Private Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA" (ByRef lpDevMode As DEVMODE, ByVal dwFlags As Long) As Long
Private Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVallpszDeviceName As String, ByVal iModeNum As Long, ByRef lpDevMode As DEVMODE) As Long

Const DM_PELSHEIGHT As Long = &H100000
Const DM_PELSWIDTH As Long = &H80000
Const DM_BITSPERPEL As Long = &H40000
Const DM_DISPLAYFREQUENCY As Long = &H400000

Const CCHDEVICENAME As Long = 32
Const CCHFORMNAME As Long = 32
Const CDS_TEST = &H4

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

'-------------------------------------------------------------------------------------------
' LngWidth //屏幕的宽(单位象素)
' LngHeight //屏幕的高(单位象素)
' IntColor //多少位颜色(e.g 16 or 32)
' LngFrequency //屏幕的刷新频率
'
'声明:
' 调用该函数时要确定所设置的值在系统所允许的设置范围内,比如系统的最大刷新频率位80,而你
' 用把LngFrequency设位85,这样将带来无法预测的后果。
'------------------------------------------------------------------------------------------
Function SetDisplaymode(LngWidth As Long, LngHeight As Long, IntColor As Integer, LngFrequency As Long) As Long
Dim NewDevmode As DEVMODE
Dim lngP As Long

'obtains information
EnumDisplaySettings 0&, 0&, NewDevmode

With NewDevmode
.dmFields = DM_PELSHEIGHT Or DM_PELSWIDTH Or DM_BITSPERPEL Or DM_DISPLAYFREQUENCY
.dmPelsWidth = LngWidth
.dmPelsHeight = LngHeight
.dmBitsPerPel = IntColor
.dmDisplayFrequency = LngFrequency
End With

SetDisplaymode = ChangeDisplaySettings(NewDevmode, CDS_TEST)
End Function

'调用方法
'Call SetDisplaymode(宽度,高度,色彩位数,刷新率)
已赞过 已踩过<
你对这个回答的评价是?
评论 收起
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式