将光标移到/点击文章中的句子上,可以查看译文。      显示繁体中文内容    显示简体中文内容

Get real primary screen in c# with a multi monitor setup?
在 C#的多显示器设置中,获得真正的主屏幕?

I have a c# windows application that work with multimonitors.the application has a main form that must be showed in the primary display and a full screen form that needs to be displayed on the second screen (this second form is showed in a 3d goggles).this is my way to assign the screens :Screen.AllScreens[0] for first screen and Screen.AllScreens[1] for secondary screen but i'm having problems with a new version of the 3d goggles because this are HDMI and even if i set the main screen to the monitor (DVI), the goggles are set as screen 1.

Could be a better way to use Screen.AllScreens[0].Bounds.X == 0 as a way to check if the screen 0 is the primary screen?

Update : i used before Screen.AllScreens[x] the property Screen.PrimaryScreen but that property also give me troubles with some monitor-goggles configuration that i really don't remember them.

时间: 作者:

Note that in Windows, it is possible to move the primary/secondary display to any position (I spent several years with my secondary monitor on top of the primary) and thus checking for bounds would be useless.

Instead, note that the Screen class has a Primary Property to check whether a given screen is primary.you could thus


secondaryScreen = Screen.AllScreens
. Where(s => s.Primary == false)
. Single();//Note: this will throw an exception if there isn't a secondary screen, or more than one.

... or the PrimaryScreen static Property to get the primary Screen directly.

原作者:
...