Solved

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

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

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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…

776 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