Winform窗口实现多显示屏显示的2种方法
一台主机连接了2台显示器(2个显卡),要求一个程序的两个窗体在不同的显示器上显示:显示器1显示From1,显示器2 显示From2。代码及说明如下:
Form1不需要变更代码,From2添加如下代码:
//方法一:
From2frm2=newFrom2();
if(Screen.AllScreens.Count()!=1)
{
frm2.Left=Screen.AllScreens[0].Bounds.Width;
frm2.Top=0;
frm2.Size=newSystem.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=newSystem.Drawing.Size(Screen.AllScreens[1].Bounds.Width,Screen.AllScreens[1].Bounds.Height);
说明:
获取当前系统连接的屏幕数量:Screen.AllScreens.Count();
获取当前屏幕的名称:stringCurrentScreenName=Screen.FromControl(this).DeviceName;
获取当前屏幕对象:ScreenCurrentScreen=Screen.FromControl(this);
获取当前鼠标所在的屏幕:ScreenCurrentScreen=Screen.FromPoint(newPoint(Cursor.Position.X,Cursor.Position.Y));
热门推荐
10 五一公司放假祝福语简短
11 追星女孩的祝福语简短
12 给长辈端午祝福语 简短
13 生日祝福语有诗意简短
14 团圆日祝福语简短
15 中秋商务祝福语简短最新
16 温暖文艺简短祝福语短句
17 男孩上学祝福语简短的
18 入住酒店文案祝福语简短