Solved

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

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

Accepted Solution

by:
Kyle Abrahams earned 500 total points
Comment Utility
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
Comment Utility
That works well. Thanks!
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

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)…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Illustrator's Shape Builder tool will let you combine shapes visually and interactively. This video shows the Mac version, but the tool works the same way in Windows. To follow along with this video, you can draw your own shapes or download the file…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

763 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

Need Help in Real-Time?

Connect with top rated Experts

7 Experts available now in Live!

Get 1:1 Help Now