如何在第二台显示器上显示windows form application? [英] How to display windows form applicationin 2nd monitor?

查看:97
本文介绍了如何在第二台显示器上显示windows form application?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嘿伙计们我真的需要知道如何使用我的扩展显示器作为输出屏幕。



例如:



如果你点击主屏幕上的按钮,windows表格应用程序将在第二个屏幕或扩展显示器中弹出。



i非常需要你的帮助人。

解决方案

假设您知道哪个辅助监视器,您希望窗体显示在哪个哪个应用程序的Screen.AllScreens属性返回的屏幕数组中的屏幕对象。

  private   bool  SetFormToSecondaryScreenPosition(Form formToPosition, int  whichMonitor)
{
// 获取所有屏幕...
Screen [] theScreens = Screen.AllScreens;

// 现实检查
// 只有一个监视器,或者没有监视器匹配'whichMonitor中的索引值?
if (theScreens.Length == 1 ||(whichMonitor > theScreens .Length)) return false ;

// 预防措施,以避免可能出现的奇怪副作用
formToPosition.StartPosition = FormStartPosition.Manual;
formToPosition.WindowState = FormWindowState.Normal;

formToPosition.Location = theScreens [whichMonitor] .WorkingArea.Location;

return true ;
}

我好几年没用过第二台显示器了,所以我没有在新的.NET框架,VS 2013和Win 8 / 8.1下测试过这段代码。如果这不能正常工作,请告诉我。


hey guys i really need to know how to use my extended monitor as an output screen only.

example:

if you click the button in the main screen the windows form application will pop out in the 2nd screen or the extended monitor.

i badly need your help guys.

解决方案

Assume you that you know which secondary monitor you want the Form to display in is associated with which Screen object in the Array of Screens returned by the Screen.AllScreens Property of the Application.

private bool SetFormToSecondaryScreenPosition(Form formToPosition, int whichMonitor)
{
    // get all the screens ...
    Screen[] theScreens = Screen.AllScreens;

    // reality check
    // only one monitor, or no monitor matching the index value in 'whichMonitor ?
    if (theScreens.Length == 1 || (whichMonitor > theScreens.Length)) return false;

    // precaution to avoid possible strange side-effects
    formToPosition.StartPosition = FormStartPosition.Manual;
    formToPosition.WindowState = FormWindowState.Normal;

    formToPosition.Location = theScreens[whichMonitor].WorkingArea.Location;

    return true;
}

I have not used a second monitor in several years, so I have not tested this code in the newer .NET frameworks, and in VS 2013, and under Win 8/8.1. Please let me know if this does not work properly.


这篇关于如何在第二台显示器上显示windows form application?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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