C# winfrom 投屏显示窗体,可以显示在指定的屏幕,有多个屏幕都可以显示
核心代码:
public void FormStartScreen(int screen, Form form)
{
if (Screen.AllScreens.Length < screen)
{
MessageBox.Show("当前主机连接最多的屏幕是" + Screen.AllScreens.Length + " 个,不能投屏到第"+ screen + "个 屏幕!");
return;
}
screen = screen-1;
if (form==null)
{
form =new Form ();
}
form.StartPosition = FormStartPosition.CenterScreen;
Screen s = Screen.AllScreens[screen];
form.Location = new System.Drawing.Point(s.Bounds.X, s.Bounds.Y);
//form.WindowState = FormWindowState.Maximized;
form.Size = new Size(s.WorkingArea.Width, s.WorkingArea.Height);
form.Show();
form.BringToFront();
}