双屏显示1 // 利用WinForm中的Screen类,即可比较方便地实现多窗体分别在多个屏幕上显示。
//•获取当前系统连接的屏幕数量: 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));
//•让窗体在第2个屏幕上显示:
//this.Left = ((Screen.AllScreens[1].Bounds.Width - this.Width) / 2);
//this.Top = ((Screen.AllScreens[1].Bounds.Height - this.Height) / 2);
private void showOnMonitor(int showOnMonitor)
{
Screen[] sc;
sc = Screen.AllScreens;
if (showOnMonitor >= sc.Length)
{
showOnMonitor = ;
}
this.FormBorderStyle = FormBorderStyle.None; //无边框全屏显示
this.StartPosition = FormStartPosition.Manual;
this.Location = new Point(sc[showOnMonitor].Bounds.Left, sc[showOnMonitor].Bounds.Top);
//this.Location = new Point(((sc[showOnMonitor].Bounds.Width-this.Width)/2), ((sc[showOnMonitor].Bounds.Height-this.Height)/2));
// If you intend the form to be maximized, change it to normal then maximized.
//this.WindowState = FormWindowState.Normal;
this.WindowState = FormWindowState.Maximized;//最大化窗口 } 如果接双显卡时showOnMonitor 参数等于0为主屏,1为扩展屏
双屏显示1
双屏显示2
private void showOnMonitor2()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form1 f = new Form1();
f.FormBorderStyle = FormBorderStyle.None;
f.Left = sc[].Bounds.Width;
f.Top = sc[].Bounds.Height;
f.StartPosition = FormStartPosition.Manual;
f.Location = sc[].Bounds.Location;
Point p = new Point(sc[].Bounds.Location.X, sc[].Bounds.Location.Y);
f.Location = p;
f.WindowState = FormWindowState.Maximized;
f.Show();
} 接入双显卡时sc[]为主屏、sc[]扩展屏
双屏显示2
一个窗体双屏显示 this.Location = new Point(,);
Screen[] sc;
sc = Screen.AllScreens;
this.Width = (sc[].Bounds.Width + sc[].Bounds.Width);//+20;
this.Height = (sc[].Bounds.Height); //+200;
this.FormBorderStyle = FormBorderStyle.None; //边框样式
webBrowser1.Width = sc[].Bounds.Width;
webBrowser1.Height = sc[].Bounds.Height;
webBrowser1.Location = new Point(sc[].Bounds.Location.X, sc[].Bounds.Location.Y);
webBrowser1.Url = new Uri("http://www.google.com.hk"); webBrowser2.Width = sc[].Bounds.Width;
webBrowser2.Height = sc[].Bounds.Height;
webBrowser2.Location = new Point(sc[].Bounds.Location.X, sc[].Bounds.Location.Y);
webBrowser2.Url = new Uri("http://www.baidu.com");
一个窗体双屏显示
此处为了知识记录用,出处:http://www.cnblogs.com/zzcong/archive/2012/06/13/2547877.html