0

I would like a simple if statement, with I can check, that my Form on which sreen locates.

Something like this pseudo code:

If (...my Form locates on the primary screen...) Then
            screenWidth = Screen.AllScreens(0).Bounds.Width
            screenHeight = Screen.AllScreens(0).Bounds.Height
Else
            screenWidth = Screen.AllScreens(1).Bounds.Width
            screenHeight = Screen.AllScreens(1).Bounds.Height
End If
LewoSoft
  • 73
  • 1
  • 2
  • 12
  • Read the notes here: [Using SetWindowPos with multiple monitors](https://stackoverflow.com/a/53026765/7444103) – Jimi Jan 12 '21 at 14:21
  • @David Yes, thanks! I should use it like this: `Screen.FromControl(Me).Equals(Screen.AllScreens(0))` – LewoSoft Jan 12 '21 at 14:24
  • Are you wanting to check if the form is on the primary screen? – Caius Jard Jan 12 '21 at 16:23
  • @CaiusJard The primary, or the secondary maybe. This formula works it now very well: `If Screen.FromControl(Me).Equals(Screen.AllScreens(0)) Then screenWidth = Screen.AllScreens(0).Bounds.Width screenHeight = Screen.AllScreens(0).Bounds.Height Else screenWidth = Screen.AllScreens(1).Bounds.Width screenHeight = Screen.AllScreens(1).Bounds.Height End If` – LewoSoft Jan 13 '21 at 10:27
  • I don't quite understand why it's not just `Screen.FromControl(Me).Bounds.Width` - you're saying "if the screen the form is on is screen 0 then get screen 0's size, otherwise screen 1" - what if there is no screen 1? What if the form is on screen 2? – Caius Jard Jan 13 '21 at 14:02

0 Answers0