我如何确定哪些监控我的.NET Windows窗体程序上运行? [英] How do I determine which monitor my .NET Windows Forms program is running on?

查看:214
本文介绍了我如何确定哪些监控我的.NET Windows窗体程序上运行?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,我要确保,如果用户移动到人会出现第二个显示器上一个C#Windows应用程序。我需要保存主窗体的大小,位置和窗口状态 - 我已经处理 - 但我还需要了解哪些屏幕是当用户关闭应用程序的

I have a C# Windows application that I want to ensure will show up on a second monitor if the user moves it to one. I need to save the main form's size, location and window state - which I've already handled - but I also need to know which screen it was on when the user closed the application.

我使用Screen类来确定当前屏幕的尺寸,但我无法找到如何确定哪个筛选应用程序上运行任何东西。

I'm using the Screen class to determine the size of the current screen but I can't find anything on how to determine which screen the application was running on.

编辑:感谢您的答复,大家好!我想,以确定哪些监测窗子上,所以我可以做正确的边界检查,以防用户不小心把窗口查看区域外或改变屏幕尺寸,其形式不会是完全可见了。

Thanks for the responses, everyone! I wanted to determine which monitor the window was on so I could do proper bounds checking in case the user accidentally put the window outside the viewing area or changed the screen size such that the form wouldn't be completely visible anymore.

推荐答案

您能得到您已使用该code屏幕的数组。

You can get an array of Screens that you have using this code.

Screen[] screens = Screen.AllScreens;

您也可以找出哪个屏幕上,通过运行该code(是Windows窗体你是)

You can also figure out which screen you are on, by running this code (this is the windows form you are on)

Screen screen = Screen.FromControl(this); //this is the Form class

在短期退房Screen类和静态辅助方法,它们可以帮助你。

in short check out the Screen class and static helper methods, they might help you.

MSDN链接,没有much..I通过自己在code建议瞎搞。

MSDN Link, doesn't have much..I suggest messing around in the code by yourself.

这篇关于我如何确定哪些监控我的.NET Windows窗体程序上运行?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆