Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

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

Posted on 2014-04-02
2
Medium Priority
?
491 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 41

Accepted Solution

by:
Kyle Abrahams earned 2000 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

NEW Veeam Backup for Microsoft Office 365 1.5

With Office 365, it’s your data and your responsibility to protect it. NEW Veeam Backup for Microsoft Office 365 eliminates the risk of losing access to your Office 365 data.

Question has a verified solution.

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

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…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
this video summaries big data hadoop online training demo (http://onlineitguru.com/big-data-hadoop-online-training-placement.html) , and covers basics in big data hadoop .
Loops Section Overview
Suggested Courses

886 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