When I run this VB.NET code in my WinForms program it displays the expected results if Monitor #1 is on the left, and Monitor #2 is on the right. (And Monitor #1 contains the Windows TaskBar.)
But if the user has his monitors switched around, with Monitor #2 on the left (containing the TaskBar), and #1 on the right... the height is now wrong. My code then (incorrectly) assumes the Monitor with the TaskBar has a LARGER value for the height.
Is there a way to fix that? (Without forcing 1000s of users to switch their Monitors around... or switch the TaskBars to the other monitor.)
Or am I totally misunderstanding "WorkingArea()"????
Dim msg As String = ""
Dim numberOfMonitors As Int16 = Screen.AllScreens.GetUpperBound(0) + 1
If (numberOfMonitors >= 1) Then msg &= "Monitor #1 = " & Screen.AllScreens(0).WorkingArea.Width & " x " & Screen.AllScreens(0).WorkingArea().Height & ". "
If (numberOfMonitors >= 2) Then msg &= "Monitor #2 = " & Screen.AllScreens(1).WorkingArea.Width & " x " & Screen.AllScreens(1).WorkingArea().Height & ". "
Call MsgBox(msg)
No you are not misunderstanding Working area. Here is the definition from MSDN
The working area is the desktop area of the display, excluding taskbars, docked windows, and docked tool bars.
WorkingArea will return the entire area of the screen if the Windows Taskbar is set to Auto-Hide, no matter whether the Taskbar is currently displayed or not.
I would look into two propertys of the Screen class one is Primary
which returns a Boolean value indicating wether or not that screen is the Primary, the second is just use the PrimaryScreen
Property to get the Working area of your Primary Screen.
Caveat: I do not have a dual monitor system powered up at this time to verify if this works.