Run the application in a dual-screen environment

Possible duplicate:
How to find on which screen the application in C # works

Any ideas to check if the current application is running on the main screen or not in a dual screen environment? I am using VSTS 2008 + C # + .Net 3.5. I want to add code to my application to determine if the current application is running on the main screen or not.

thanks in advance George

+2
c # multiple-monitors
Jun 24 '09 at 18:09
source share
2 answers

You can use the Screen class, which can tell you whether the control is on a particular screen or not. You can also get initial monitoring, and each Screen object also has a Primary property, which indicates whether it is primary or not.

Here is the msdn article .

You should use it as follows:

var monitor = Screen.FromControl(this); if (monitor.Primary) //the monitor returned is the primary monitor 
+4
Jun 24 '09 at 18:15
source share

NOT TESTED: (currently no dual-screen setup required for testing)

 bool onPrimary = this.Bounds.IntersectsWith(Screen.PrimaryScreen.Bounds); 

where "this" is the main form of your application.

EDIT: Just test it, it works as expected.

+1
Jun 24 '09 at 18:14
source share



All Articles