run application on a dual screen environment [duplicate]
Asked Answered
S

2

2

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

Secor answered 24/6, 2009 at 18:9 Comment(0)
C
4

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
Cirque answered 24/6, 2009 at 18:15 Comment(0)
D
1

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.

Demission answered 24/6, 2009 at 18:14 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.