我正試圖編寫一個程序,在兩個屏幕上打開一個窗口。 我希望全屏顯示兩個顯示器上的兩個窗口。第二臺顯示器上的全屏窗口
所以我使用了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