我正试图编写一个程序,在两个屏幕上打开一个窗口。 我希望全屏显示两个显示器上的两个窗口。第二台显示器上的全屏窗口
所以我使用了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();
}
}
我并设置将WindowState最大化窗口2,但然后窗口2在屏幕上一个打开。 任何人都知道我可以如何解决这个问题?
您的打开窗户犯规让你想要它在屏幕上的任何引用代码,所以是的,它会出现在主屏幕上 – BugFinder