Winform多显示屏显示 Winform窗口实现多显示屏显示的2种方法
人气:0想了解Winform窗口实现多显示屏显示的2种方法的相关内容吗,在本文为您仔细讲解Winform多显示屏显示的相关知识和一些Code实例,欢迎阅读和指正,我们先划重点:Winform,窗口,多显示屏,显示,下面大家一起来学习吧。
一台主机连接了2台显示器(2个显卡),要求一个程序的两个窗体在不同的显示器上显示:显示器1 显示From1,显示器2 显示From2。代码及说明如下:
Form1不需要变更代码,From2添加如下代码:
// 方法一: From2 frm2 = new From2(); if (Screen.AllScreens.Count() != 1) { frm2.Left = Screen.AllScreens[0].Bounds.Width; frm2.Top = 0; frm2.Size = new System.Drawing.Size(Screen.AllScreens[1].Bounds.Width, Screen.AllScreens[1].Bounds.Height); } // 方法二: this.Left = ((Screen.AllScreens[1].Bounds.Width - this.Width) / 2); this.Top = ((Screen.AllScreens[1].Bounds.Height - this.Height) / 2); this.Size = new System.Drawing.Size(Screen.AllScreens[1].Bounds.Width, Screen.AllScreens[1].Bounds.Height);
说明:
获取当前系统连接的屏幕数量: Screen.AllScreens.Count();
获取当前屏幕的名称:string CurrentScreenName = Screen.FromControl(this).DeviceName;
获取当前屏幕对象:Screen CurrentScreen = Screen.FromControl(this);
获取当前鼠标所在的屏幕:Screen CurrentScreen = Screen.FromPoint(new Point(Cursor.Position.X, Cursor.Position.Y));
加载全部内容