Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I tell which monitor a form is on when there are more than 2 monitors

Posted on 2011-03-10
2
Medium Priority
?
341 Views
Last Modified: 2012-06-27
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...
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

Open in new window

0
Comment
Question by:indy500fan
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 96

Accepted Solution

by:
Bob Learned earned 2000 total points
ID: 35102414
I would think that you could test if the form's location is within the working area of a Screen.

Untested example:

For Each screen As Screen In Screen.AllScreens
    If screen.WorkingArea.Contains(Me.Location) Then
    End If
Next screen

Open in new window

0
 

Author Comment

by:indy500fan
ID: 35143127
Bob,

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
0

Featured Post

Veeam Task Manager for Hyper-V

Task Manager for Hyper-V provides critical information that allows you to monitor Hyper-V performance by displaying real-time views of CPU and memory at the individual VM-level, so you can quickly identify which VMs are using host resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Many of us here at EE write code. Many of us write exceptional code; just as many of us write exception-prone code. As we all should know, exceptions are a mechanism for handling errors which are typically out of our control. From database errors, t…
Real-time is more about the business, not the technology. In day-to-day life, to make real-time decisions like buying or investing, business needs the latest information(e.g. Gold Rate/Stock Rate). Unlike traditional days, you need not wait for a fe…
Video by: ITPro.TV
In this episode Don builds upon the troubleshooting techniques by demonstrating how to properly monitor a vSphere deployment to detect problems before they occur. He begins the show using tools found within the vSphere suite as ends the show demonst…
Have you created a query with information for a calendar? ... and then, abra-cadabra, the calendar is done?! I am going to show you how to make that happen. Visualize your data!  ... really see it To use the code to create a calendar from a q…

610 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question