用户登录  |  用户注册
首 页商业源码原创产品编程论坛
当前位置:PB创新网文章中心编程技巧VisualBasic

用VB改变屏幕的分辨率和刷新频率

减小字体 增大字体 作者:佚名  来源:本站整理  发布时间:2009-03-16 19:54:41

Option Explicit

Public Declare Function ChangeDisplaySettings Lib "user32.dll" Alias "ChangeDisplaySettingsA"

(ByRef lpDevMode As DEVMODE, ByVal dwFlags As Long) As Long
Public Declare Function EnumDisplaySettings Lib "user32.dll" Alias "EnumDisplaySettingsA" (ByVal

lpszDeviceName 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,这样将带来无法预测的后果。
''------------------------------------------------------------------------------------------
Public 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

Tags:

作者:佚名

文章评论评论内容只代表网友观点,与本站立场无关!

   评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
PB创新网ourmis.com】Copyright © 2000-2009 . All Rights Reserved .
页面执行时间:27,421.88000 毫秒
Email:ourmis@126.com QQ:2322888 蜀ICP备05006790号