user3368481
user3368481

Reputation:

Get screen size with two monitor

I using this code for get height an with of the screen size :

 Dim hdcSrc As IntPtr = User32.GetWindowDC(handle)       
 Dim windowRect As New User32.RECT
 User32.GetWindowRect(handle, windowRect)
 Dim width As Integer = windowRect.right - windowRect.left
 Dim height As Integer = windowRect.bottom - windowRect.top

now,When we have two monitors of different sizes. Which is considered the default monitor?

Upvotes: 0

Views: 947

Answers (2)

Steve
Steve

Reputation: 216353

There is a useful class in the Net Framework that could easily substitute your code.

Screen class

And the primary screen is obtained using

Screen.PrimaryScreen

For example your code above is replaceable using

Dim area As Rectangle = Screen.PrimaryScreen.Bounds
Console.WriteLine("Width: " & area.Width.ToString)
Console.WriteLine("Height: " & area.Height.ToString)

Upvotes: 2

All this are available in the Screen class:

Screen.AllScreens

And

Screen.PrimaryScreen

Upvotes: 0

Related Questions