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
Solved

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

Posted on 2014-04-02
2
464 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
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

Master Your Team's Linux and Cloud Stack

Come see why top tech companies like Mailchimp and Media Temple use Linux Academy to build their employee training programs.

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…
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

808 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