Solved

Multiple monitors: How can I tell if a windows form is being displayed on a disconnected screen?

Posted on 2014-04-02
2
465 Views
Last Modified: 2014-04-03
I have a vb.net windows form app that remembers the .top and .left properties of some of its forms and then sets them each time the program is run.

The program is now run on a SurfacePro tablet which is docked to a Targus SuperSpeed USB 3 station and uses DisplayLink to drive 2 external 24" monitors in addition to the tablet's touch screen.

The program's forms are positioned on the external monitors and everything works well until the tablet is undocked and reverts to a single screen system. When the app is run, it still displays its forms on the disconnected monitors instead of the primary screen.

How do you programmatically (vb) determine if a windows form is being displayed on a monitor that is not connected (or visible)?
0
Comment
Question by:ou81aswell
[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 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 39972904
From:
http://msdn.microsoft.com/en-us/library/system.windows.forms.screen.aspx

 Dim screenWidth as Integer = Screen.PrimaryScreen.Bounds.Width
 Dim screenHeight as Integer = Screen.PrimaryScreen.Bounds.Height


'might be .length instead of .count
if Screen.AllScreens.Count = 1 andalso   form.Top > screenHeight then
  form.Top = 100
end if

'might be .length instead of .count
if Screen.AllScreens.Count = 1  andalso form.Left > screenWidth then
   form.Left = 100
end if
0
 

Author Closing Comment

by:ou81aswell
ID: 39975271
That works well. Thanks!
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Welcome my friends to the second instalment and follow-up to our Minify and Concatenate Your Scripts and Stylesheets (http://www.experts-exchange.com/Programming/Languages/.NET/ASP.NET/A_4334-Minify-and-Concatenate-Your-Scripts-and-Stylesheets.html)…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

735 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