〥羽〥 發表於 2009-6-19 22:35:09

C# 在雙顯示器顯示windows form

This sample code shows how to Show windows form on dual monitor



function void showOnMonitor1()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
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();
}



function void showOnMonitor2()
{
Screen[] sc;
sc = Screen.AllScreens;
//get all the screen width and heights
Form2 f = new Form2();
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();
}
頁: [1]
查看完整版本: C# 在雙顯示器顯示windows form