我如何确保表单显示在“附加"页面上?在双显示器场景中监控? [英] How do I ensure a form displays on the "additional" monitor in a dual monitor scenario?

查看:14
本文介绍了我如何确保表单显示在“附加"页面上?在双显示器场景中监控?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个应用程序,其中有一个表单,我想在第二个屏幕上显示.

I have an application in which there is a form which I want to show on second screen.

平均如果应用程序在屏幕 A 上运行,当我单击菜单以显示表单时,它应该显示在屏幕 B 上如果应用程序在屏幕 B 上运行,并且当我单击菜单以显示表单时,它应该显示在屏幕 A 上.

Mean If application is running on screen A and when I click on menu to show Form it should display on Screen B and same with if application is running on screen B and when I click on menu to show Form it should display on Screen A.

推荐答案

您需要使用 Screen 类来查找原始表单不在的屏幕,然后根据那个屏幕的Bounds.

例如:

var myScreen = Screen.FromControl(originalForm);
var otherScreen = Screen.AllScreens.FirstOrDefault(s => !s.Equals(myScreen)) 
               ?? myScreen;
otherForm.Left = otherScreen.WorkingArea.Left + 120;
otherForm.Top = otherScreen.WorkingArea.Top + 120;

这适用于任意数量的屏幕.

This will work for any number of screens.

请注意,显卡的配置可能使 Windows 看到一个大屏幕而不是两个小屏幕,在这种情况下,这会变得更加困难.

Note that it is possible that the video card is configured so that Windows sees one large screen instead of two smaller ones, in which case this becomes much more difficult.

这篇关于我如何确保表单显示在“附加"页面上?在双显示器场景中监控?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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