title: VB.net - Windows.Forms.Screen.AllScreens report wrong bound sizes when using any DPI scaling above 125%, anyway to fix this?
body: <p>I have my vb.net application (written in  VS2010 pro) setup to detect and support multi-monitor setups at various DPI scaling. </p>
  
  <p>I use Screen.AllScreens.Length to get me how many monitors I have running:</p>
  
  <pre><code>Public Function getMonitorCount() As Integer
      Return Screen.AllScreens.Length
  End Function
  </code></pre>
  
  <p>And then I loop through all the monitors to get their various info:</p>
  
  <pre><code>Public Sub getMonitorSetupFull()
      m = getMonitorCount()
      n = 0
      Do While n &lt; m
          Monitor(n) = Windows.Forms.Screen.AllScreens(n)
          XLeft(n) = Monitor(n).Bounds.X
          YTop(n) = Monitor(n).Bounds.Y
          XRight(n) = XLeft(n) + Monitor(n).Bounds.Width
          YBottom(n) = YTop(n) + Monitor(n).Bounds.Height
          MonitorSize(n) = New Size(Monitor(n).Bounds.Width, Monitor(n).Bounds.Height)
          n = n + 1
      Loop
  End Sub
  </code></pre>
  
  <p>I'm having an issue where Monitor(n).Bounds (aka Windows.Forms.Screen.AllScreens(n).Bounds) give me the wrong values at high DPI. For example, at 200% DPI Monitor(n).Bounds.Height gives me a value of 540 for a 1080p monitor (precisely half). At 100%/125% DPI, I get at 1080 which is correct but at 126% DPI I get 857 instead of 1080.</p>
  
  <p>Is there something I can add to my code to get Windows.Forms.Screen.AllScreens(n).Bounds to detect the proper sizes at these DPI or should I just manually compensate for this eccentric behavior myself via something along the lines of if DPI > 125%, Windows.Forms.Screen.AllScreens(n).Bounds.Height = Windows.Forms.Screen.AllScreens(n).Bounds.Height * DPIratio ? </p>
  
  <p><strong>UPDATE:</strong> To confound this issue even more, I found that if I select use Windows XP DPI scaling while I'm setting the DPI, this issue doesn't occur. Nor does it occur when I'm not using Aero. I've reproduced this on other Windows 7 machines.</p>