温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

VB.NET中怎么设置屏幕分辨率

发布时间:2021-07-27 14:40:13 来源:亿速云 阅读:395 作者:Leah 栏目:开发技术

这篇文章将为大家详细讲解有关VB.NET中怎么设置屏幕分辨率,文章内容质量较高,因此小编分享给大家做个参考,希望大家阅读完这篇文章后对相关知识有一定的了解。

代码如下:


Private Declare Function GetDeviceCaps Lib "gdi32" (ByVal hdc As Long, ByVal nIndex As Long) As Long
Private Declare Function ChangeDisplaySettings Lib "user32" Alias "ChangeDisplaySettingsA" (lpDevMode As Any, ByVal dwflags As Long) As Long
Private Const CCDEVICENAME As Long = 32
Private Const CCFORMNAME As Long = 32
Private Const DM_BITSPERPEL As Long = &H40000
Private Const DM_PELSWIDTH As Long = &H80000
Private Const DM_PELSHEIGHT As Long = &H100000
Private Const DM_DISPLAYFLAGS As Long = &H200000
Private Const DM_DISPLAYFREQUENCY = &H400000
Private Const CDS_FORCE As Long = &H80000000
Private Const BITSPIXEL As Long = 12
Private Const HORZRES As Long = 8
Private Const VERTRES As Long = 10
Private Const VREFRESH = 116
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
Private Sub cmdChangeDesktopMode_Click()
    Dim DM As DEVMODE
    With DM
       .dmPelsWidth = CInt(txtNewWidth.Text)
       .dmPelsHeight = CInt(txtNewHeight.Text)
       .dmBitsPerPel = CInt(txtNewColor.Text)
       .dmDisplayFrequency = CInt(txtNewFreq.Text)
       .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT Or DM_BITSPERPEL Or DM_DISPLAYFREQUENCY
       .dmSize = LenB(DM)
    End With
    If ChangeDisplaySettings(DM, CDS_FORCE) <> 0 Then
        MsgBox "错误!不支持此模式!"
    End If
End Sub
Private Sub Form_Load()
   txtOldWidth.Text = GetDeviceCaps(Me.hdc, HORZRES)
   txtOldHeight.Text = GetDeviceCaps(Me.hdc, VERTRES)
   txtOldColor.Text = GetDeviceCaps(Me.hdc, BITSPIXEL)
   txtOldFreq.Text = GetDeviceCaps(Me.hdc, VREFRESH)
End Sub

关于VB.NET中怎么设置屏幕分辨率就分享到这里了,希望以上内容可以对大家有一定的帮助,可以学到更多知识。如果觉得文章不错,可以把它分享出去让更多的人看到。

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI