indy500fan
asked on
How do I tell which monitor a form is on when there are more than 2 monitors
Friends,
I have used a routine in the past to reopen a form on a dual screen setup; however, my company now has a four monitor setup where they run this app.
I tried the attached code, but I cannot make it work, it never correctly identifies the right monitor that the ResultViewerForm is on...
Even if I have the form on the second display, it shows that the display (i) is zero.
I want to use this saved in the application properties, to open subsequent forms in the same location/screen.
Thanks in advance!
When I run the attached code, here are my variables on the second loop through...:
i 1 Integer
String1 "\\.\DISPLAY2" String
String2 "\\.\DISPLAY1," String
The thing I don't understand is that String2 should say DISPLAY2, because that is the monitor it is on:
I guess what I need help with, is how do I get the form to tell me which screen it's on...
I have used a routine in the past to reopen a form on a dual screen setup; however, my company now has a four monitor setup where they run this app.
I tried the attached code, but I cannot make it work, it never correctly identifies the right monitor that the ResultViewerForm is on...
Even if I have the form on the second display, it shows that the display (i) is zero.
I want to use this saved in the application properties, to open subsequent forms in the same location/screen.
Thanks in advance!
When I run the attached code, here are my variables on the second loop through...:
i 1 Integer
String1 "\\.\DISPLAY2" String
String2 "\\.\DISPLAY1," String
The thing I don't understand is that String2 should say DISPLAY2, because that is the monitor it is on:
I guess what I need help with, is how do I get the form to tell me which screen it's on...
For i As Integer = 0 To Screen.AllScreens().Length - 1
Dim String1 As String = stringtoasc(Screen.AllScreens(i).DeviceName.ToString)
Dim String2 As String = stringtoasc(Screen.FromControl(ResultViewerForm).DeviceName.ToString)
If String1 = String2 Then
My.Settings.StartupLocation_Scrn = i
End If
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I'm glad you responded. I'm going to test your suggestion, but I had to move on with a brute force solution. Looking at it, I think it will work (you've not led me wrong in the past), so I will accept your suggestion as the solution.
Thanks,
Eric