输出到另一个窗口 [英] Output to another Window

查看:101
本文介绍了输出到另一个窗口的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法在VB.NET中指示表单在第二个监视器中打开并最大化。也就是说,如果显示两个监视器,默认情况下第二个窗口中的窗体加载最大化?



假设一个程序是用两个窗体制作的,一台计算机有两个监视器附件。



我希望默认情况下FormA在MonitorA中显示,默认情况下FormB在MonitorB中显示最大化。



<编辑:为了清晰起见,进一步编辑。

解决方案

第一件事是获取有关可用屏幕的信息。你可以从 获得。 Screen.AllScreens 。接下来是确定有多少个屏幕(注意可能有两个以上)。然后你需要决定如何识别第二屏幕(例如,第一个 主要 属性为 false



完成后,我想最简单的方法是将表单移动到 Bounds ,然后最大化它。



这是一个打开在指定屏幕上最大化的表单的示例方法:

  public static void ShowMaximizedOnScreen(屏幕截图,表格形式)
{
form.Location = screen.Bounds.Location;
form.WindowState = FormWindowState.Maximized;
form.StartPosition = FormStartPosition.Manual;
form.Show();
}


Is there a way to direct a form in VB.NET to open and maximize in the second monitor. That is if there are two monitors displayed, to have the form load in the second window maximized by default?

Say a program was made with two forms and a computer has two monitors attached.

I want FormA to show in MonitorA by default and FormB to show in MonitorB maximized by default.

EDIT: Further edited for clarity.

解决方案

The first thing is to get information about available screens. You can get that from Screen.AllScreens. Next is to determine how many screens there are (note that there may be more than two). Then you need to decide how to identify the "second" screen (for instance, the first one that where the Primary property is false.

When that is done, I guess that the simplest way is to move the form to a location that is within the Bounds of the desired screen, and then maximize it.

Here is a sample method that opens a form maximized on a specified screen:

public static void ShowMaximizedOnScreen(Screen screen, Form form)
{
    form.Location = screen.Bounds.Location;
    form.WindowState = FormWindowState.Maximized;
    form.StartPosition = FormStartPosition.Manual;
    form.Show();
}

这篇关于输出到另一个窗口的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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