Is there any implemented code to get screen resolution?
I want to make a program which will work different for different screen resolutions.
Is there any implemented code to get screen resolution?
I want to make a program which will work different for different screen resolutions.
Just do the following, its already built into the Framework.
Dim screenWidth as Integer = Screen.PrimaryScreen.Bounds.Width
Dim screenHeight as Integer = Screen.PrimaryScreen.Bounds.Height
Note that before asking, research. This has been answered already and was found with a quick Google Search - Getting Screen Resolution
My solution will work also for extended desktops (dual-screen)
''' <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:
' Usage Examples:
MsgBox(GetExtendedScreenResolution.ToString)
Dim Resolution as Point = GetExtendedScreenResolution()
Me.Size = GetPrimaryScreenResolution()