• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 372
  • Last Modified:

Get Screen Resolutions in vb.net

Hello,
I'd like to determine the display resolution for each connected monitor in a multimonitor setup. It seems there are a few ways to do this, but I can't seem to find an example for implementing it in vb.net. Thanks for your help!
0
Aaron Feledy
Asked:
Aaron Feledy
1 Solution
 
Robert SchuttSoftware EngineerCommented:
I use this (adjusted from a routine found on the net) to determine the form size needed to cover all screens (for a screensaver):
        Dim EntireBounds As New Rectangle(0, 0, 0, 0)
        Dim scrn As Integer
        Dim TheScreens() As Screen = Screen.AllScreens
        For scrn = LBound(TheScreens) To UBound(TheScreens)
            If TheScreens(scrn).Bounds.X + TheScreens(scrn).Bounds.Width > EntireBounds.Width Then
                EntireBounds.Width = TheScreens(scrn).Bounds.X + TheScreens(scrn).Bounds.Width
            End If
            If TheScreens(scrn).Bounds.Y + TheScreens(scrn).Bounds.Height > EntireBounds.Height Then
                EntireBounds.Height = TheScreens(scrn).Bounds.Y + TheScreens(scrn).Bounds.Height
            End If
        Next scrn
        Me.Bounds = EntireBounds

Open in new window

The essence is the For Next loop, if you need to do something with each screen separately then inside the loop is the place to be ;-)
0
 
ArkCommented:
       For Each scrn As Screen In Screen.AllScreens
            Debug.Print(scrn.Bounds.Width & "x" & scrn.Bounds.Height)
        Next

Open in new window

0
 
Aaron FeledyDrupal Developer and ConsultantAuthor Commented:
Simple and does exactly what I need.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: SQL Server Core 2016

This course will introduce you to SQL Server Core 2016, as well as teach you about SSMS, data tools, installation, server configuration, using Management Studio, and writing and executing queries.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now