Possible Duplicate:
How do I find what screen the application is running on in C#
Any ideas to check whether current application is run on primary screen or not in a dual screen environment? I am using VSTS 2008 + C# + .Net 3.5. I want to add code in my application to detect whether current application is run on primary screen or not.
thanks in advance, George
You can use the Screen class which can tell you whether or not a control is on a particular screen or not. You can also get the primary monitory, and every Screen object also has a Primary property which indicates whether or not it is the primary monitory.
Here's the msdn article.
You should be able to use it like this:
var monitor = Screen.FromControl(this);
if (monitor.Primary) //the monitor returned is the primary monitor
NOT TESTED: (don't have a dual screen setup at the moment to test on)
bool onPrimary = this.Bounds.IntersectsWith(Screen.PrimaryScreen.Bounds);
where "this" is the main form of your application.
EDIT: Just tested it, it works as expected.
来源:https://stackoverflow.com/questions/1039979/run-application-on-a-dual-screen-environment