Tadumc421
Tadumc421

Reputation: 159

How to detect the screen DPI using VB.NET?

I need the screen DPI so i can adjust my program accordingly.

So my question is How to detect the screen DPI using VB.NET?

Upvotes: 1

Views: 4699

Answers (1)

Alireza Nemeti
Alireza Nemeti

Reputation: 162

try this:

    Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
    Dim g As Graphics = Me.CreateGraphics()
    MessageBox.Show("ScreenWidth:" & Screen.PrimaryScreen.Bounds.Width & " ScreenHeight:" & Screen.PrimaryScreen.Bounds.Height & vbCrLf & " DpiX:" & g.DpiX & " DpiY:" & g.DpiY)
End Sub

Upvotes: 2

Related Questions