创建大于桌面屏幕的应用程序窗口

时间:2016-12-25 06:47:23

标签: c# wpf multiple-monitors

我正在开发一个将安装在双显示器上的应用程序(两个1920x1080 = 3840x1080)。我的开发机器是1440x900,我在开发过程中没有显示器。我无法想象如何创建一个大小为3840x1080(大于我的开发桌面屏幕)的窗口,窗口最大化为1440x900但不超出。

1 个答案:

答案 0 :(得分:0)

    One of the way in which you can do this this to analyze the form screen size.
    This is the working example:

        if (System.Windows.Forms.Screen.AllScreens.Length == 2 &&
                        System.Windows.Forms.Screen.AllScreens[0].WorkingArea.Width == System.Windows.Forms.Screen.AllScreens[1].WorkingArea.Width) {
                    // dual-display logic
                    System.Drawing.Rectangle sl = System.Windows.Forms.Screen.AllScreens[0].WorkingArea;
                    System.Drawing.Rectangle sr = System.Windows.Forms.Screen.AllScreens[1].WorkingArea;
                    Application.Current.MainWindow.Left = sl.Left;
                    Application.Current.MainWindow.Top = sl.Top;
                    Application.Current.MainWindow.Width = sr.Width + sl.Width;
                    Application.Current.MainWindow.Height = sl.Height;
} else {
                // single-display logic
                System.Drawing.Rectangle s = System.Windows.Forms.Screen.AllScreens[0].WorkingArea;
                Application.Current.MainWindow.Left = s.Left; Application.Current.MainWindow.Top = s.Top; Application.Current.MainWindow.Width = (s.Width / 2); Application.Current.MainWindow.Height = s.Height;
}

希望这对你有用。