是否有任何实现的代码可以获得屏幕分辨率?
我想制作一个针对不同屏幕分辨率工作的程序。
答案 0 :(得分:2)
只需执行以下操作,它已经内置到Framework中。
Dim screenWidth as Integer = Screen.PrimaryScreen.Bounds.Width
Dim screenHeight as Integer = Screen.PrimaryScreen.Bounds.Height
请注意,在询问,研究之前。这已经得到了解答,并通过快速的Google搜索找到了Getting Screen Resolution
答案 1 :(得分:0)
我的解决方案也适用于扩展桌面(双屏)
''' <summary>
''' Gets the extended screen resolution (for Dual-Screens).
''' </summary>
Private Function GetExtendedScreenResolution() As Point
Dim ResX As Integer =
(From scr As Screen In Screen.AllScreens Select scr.Bounds.Width).Sum
Dim ResY As Integer =
(From scr As Screen In Screen.AllScreens Select scr.Bounds.Height).Sum
Return New Point(ResX, ResY)
End Function
''' <summary>
''' Gets the primary screen resolution.
''' </summary>
Private Function GetPrimaryScreenResolution() As Point
Return New Point(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)
End Function
用法示例:
' Usage Examples:
MsgBox(GetExtendedScreenResolution.ToString)
Dim Resolution as Point = GetExtendedScreenResolution()
Me.Size = GetPrimaryScreenResolution()