|
-
Jun 18th, 2015, 09:35 PM
#1
Thread Starter
Junior Member
Screen Position
Hey
I'm working with a multi monitor setup. I know that you can do Screen.AllScreens(x) to get a specific screen, but is there any way to identify which screen is in which position?
I.E.
Screen 0 is on the right, screen 1 is on the left, screen 2 is in the middle
I'm trying to position one form at the top left of each screen, and the only way i can think to do this is something like
Code:
Me.Location = New Point(-Screen.AllScreens(1).Bounds.Width, Screen.AllScreens(1).Bounds.Top)
(That is assuming that screen 1 is on the left)
Any help?
-
Jun 18th, 2015, 09:46 PM
#2
Re: Screen Position
There's no way to determine where the monitors are physically but almost everyone with multiple monitors will match their logical layout to their physical layout and you can determine logical layout. You can get the Top and Left from the Bounds of each Screen and then compare them. Using the Left, lower numbers are on the left and higher numbers are on the right. using the Top, lower numbers are above and higher numbers are below. With a bit of maths, you can determine the relative layout of all monitors.
-
Jun 18th, 2015, 09:49 PM
#3
Thread Starter
Junior Member
Re: Screen Position
The only real problem I see with this is that Point(0, 0) relates to Monitor 0. So, To get 0,0 on the left monitor you have to do -Left Monitor Width...
-
Jun 18th, 2015, 10:25 PM
#4
Re: Screen Position
 Originally Posted by thefiscster
The only real problem I see with this is that Point(0, 0) relates to Monitor 0. So, To get 0,0 on the left monitor you have to do -Left Monitor Width...
I think I understand correctly what you're saying but, if I do, then you're wrong. Here's some code that I just tested on my own four-monitor setup at work and it puts a form in the top, left corner of each monitor in order from left to right:
vb.net Code:
Public Class Form1 Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click Dim number = 1 For Each scr In Screen.AllScreens.OrderBy(Function(s) s.Bounds.Left) Dim f As New Form With {.Text = number.ToString(), .StartPosition = FormStartPosition.Manual, .Location = scr.Bounds.Location} f.Show() number += 1 Next End Sub End Class
-
Jun 18th, 2015, 11:17 PM
#5
Re: Screen Position
jmcilhinney's code works ok with my 4 screen setup too.
try this:
Code:
Dim screens() As Screen = Screen.AllScreens
Dim order As New List(Of Screen)
order.Add(screens.First(Function(s) s.Bounds.Right = screens.Max(Function(sr) sr.Bounds.Right))) ' 0 = rightmost
order.Add(screens.First(Function(s) s.Bounds.Left = screens.Min(Function(sr) sr.Bounds.Left))) ' 1 = leftmost
order.Add(screens.Except(order).First) ' 2 = middle
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Jun 19th, 2015, 10:26 AM
#6
Thread Starter
Junior Member
Re: Screen Position
 Originally Posted by jmcilhinney
I think I understand correctly what you're saying but, if I do, then you're wrong. Here's some code that I just tested on my own four-monitor setup at work and it puts a form in the top, left corner of each monitor in order from left to right:
vb.net Code:
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim number = 1
For Each scr In Screen.AllScreens.OrderBy(Function(s) s.Bounds.Left)
Dim f As New Form With {.Text = number.ToString(),
.StartPosition = FormStartPosition.Manual,
.Location = scr.Bounds.Location}
f.Show()
number += 1
Next
End Sub
End Class
Thank you so much! I for whatever reason didn't think to order it by the Left values. Works perfect, Thanks again
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|