第二台显示器上的全屏窗口

时间:2016-08-15 12:34:02

标签: c# .net windows winforms

我试图编写一个在两个屏幕上打开窗口的程序。 我希望两个显示器上的两个窗口全屏显示。

所以我使用了win.forms功能屏幕。所有屏幕 去做。在第一个屏幕上一切都很好。但是在 二级屏幕窗口不是全屏。

所以我写了一些代码来向我展示两台显示器的价值。 我看到监视器2的值不正确。两台显示器均为192 x 1080。

但第二台显示器显示为1536 x 864。

       if (System.Windows.Forms.SystemInformation.MonitorCount < 2)
         {
             primaryScreen = System.Windows.Forms.Screen.PrimaryScreen;
         }
         else
         {
             if (screennumber == 2)
             {
                 primaryScreen = System.Windows.Forms.Screen.AllScreens[1];
                 secondaryScreen = System.Windows.Forms.Screen.PrimaryScreen;
             }
             else
             {
                 primaryScreen = System.Windows.Forms.Screen.PrimaryScreen;
                 secondaryScreen = System.Windows.Forms.Screen.AllScreens[0];
             }
         }

        if (screennumber == 2)
         {
             ScreenTwo newWindow = new ScreenTwo();
             newWindow.WindowStartupLocation = WindowStartupLocation.Manual;
             newWindow.Left = m_PrimaryScreen.WorkingArea.Left;
             newWindow.Top = m_PrimaryScreen.WorkingArea.Top;
             newWindow.Width = m_PrimaryScreen.WorkingArea.Width;
             newWindow.Height = m_PrimaryScreen.WorkingArea.Height;
             newWindow.Show();
         }
         else
         {
             ScreenOne newWindow = new ScreenOne();
             newWindow.WindowStartupLocation = WindowStartupLocation.CenterScreen;
             newWindowWindowStyle = WindowStyle.SingleBorderWindow;
             newWindow.ShowInTaskbar = true;
             newWindow.ResizeMode = ResizeMode.CanResizeWithGrip;
             newWindow.WindowState = WindowState.Maximized;
             newWindow.Show();
         }
     }

我确实将窗口状态设置为在窗口2上最大化,然后在屏幕1上打开窗口2。 谁知道我怎么解决这个问题???

0 个答案:

没有答案