正在阅读:在VB.NET中改变显示器的分辩率在VB.NET中改变显示器的分辩率

2004-03-31 15:07 出处:CSDN 作者:微软MVP 李洪根 责任编辑:sdq

  '改变分辩率过程,参数一宽度,参数二高度
  Private Sub ChangeDisp(ByRef iWidth As Single, ByRef iHeight As Single)
  Dim blnWorked As Boolean
  Dim i As Integer
  Dim DevM As Form1.DEVMODE
  i = 0
  Do
  blnWorked = EnumDisplaySettings(0, i, DevM)
  i = i + 1
  Loop Until (blnWorked = False)
  With DevM
  .dmFields = DM_PELSWIDTH Or DM_PELSHEIGHT  Or DM_DISPLAYFREQUENCY
  .dmPelsWidth = iWidth
  .dmPelsHeight = iHeight
  
  '刷新频率为85
  .dmDisplayFrequency = 85       
  End With
  Call ChangeDisplaySettings(DevM, 0)
  End Sub
  Private Sub btnGetDisp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnGetDisp.Click
  Dim X As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width
  Dim Y As Short = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height
  MsgBox("您的显示器分辨率是" & X & " X " & Y)
  End Sub
  Private Sub btnSetDisp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnSetDisp.Click
  If MsgBox("您确认要将显示器分辨率改为1024x768吗?", MsgBoxStyle.OKCancel, "系统消息") = MsgBoxResult.OK Then

  '调用改变分辩率过程
  ChangeDisp(1024, 768)
  End If
  End Sub

  程序运行如下图所示,点击设置分辩率,将会把显示器分辨率改为1024x768,刷新频率为85,是不是很简单?



察看评论详细内容 我要发表评论
作者笔名简短内容 发表时间
:
键盘也能翻页,试试“← →”键

相关文章

关注我们

最新资讯离线随时看 聊天吐槽赢奖品