2

可能重复:
如何在 C# 中找到应用程序在哪个屏幕上运行

有什么想法可以检查当前应用程序是否在双屏环境中的主屏幕上运行?我正在使用 VSTS 2008 + C# + .Net 3.5。我想在我的应用程序中添加代码来检测当前应用程序是否在主屏幕上运行。

提前谢谢,乔治

4

2 回答 2

4

您可以使用 Screen 类,它可以告诉您控件是否在特定屏幕上。您还可以获取主监视器,每个 Screen 对象也有一个 Primary 属性,指示它是否是主监视器。

这是msdn 文章

您应该可以像这样使用它:

var monitor = Screen.FromControl(this);

if (monitor.Primary) //the monitor returned is the primary monitor
于 2009-06-24T18:15:44.880 回答
1

未测试:(目前没有要测试的双屏设置)

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

其中“this”是您的应用程序的主要形式。

编辑:刚刚测试过,它按预期工作。

于 2009-06-24T18:14:56.987 回答