InPowerS.Net

 找回密碼
 註冊
搜索
查看: 3076|回復: 0

C# 在雙顯示器顯示windows form

[複製鏈接]
發表於 2009-6-19 22:35:09 | 顯示全部樓層 |閱讀模式
This sample code shows how to Show windows form on dual monitor



  1. function void showOnMonitor1()
  2. {
  3. Screen[] sc;
  4. sc = Screen.AllScreens;
  5. //get all the screen width and heights
  6. Form2 f = new Form2();
  7. f.FormBorderStyle = FormBorderStyle.None;
  8. f.Left = sc[0].Bounds.Width;
  9. f.Top = sc[0].Bounds.Height;
  10. f.StartPosition = FormStartPosition.Manual;
  11. f.Location = sc[0].Bounds.Location;
  12. Point p = new Point(sc[0].Bounds.Location.X, sc[0].Bounds.Location.Y);
  13. f.Location = p;
  14. f.WindowState = FormWindowState.Maximized;
  15. f.Show();
  16. }
複製代碼


  1. function void showOnMonitor2()
  2. {
  3. Screen[] sc;
  4. sc = Screen.AllScreens;
  5. //get all the screen width and heights
  6. Form2 f = new Form2();
  7. f.FormBorderStyle = FormBorderStyle.None;
  8. f.Left = sc[1].Bounds.Width;
  9. f.Top = sc[1].Bounds.Height;
  10. f.StartPosition = FormStartPosition.Manual;
  11. f.Location = sc[1].Bounds.Location;
  12. Point p = new Point(sc[1].Bounds.Location.X, sc[1].Bounds.Location.Y);
  13. f.Location = p;
  14. f.WindowState = FormWindowState.Maximized;
  15. f.Show();
  16. }
複製代碼
您需要登錄後才可以回帖 登錄 | 註冊

本版積分規則

小黑屋|Archiver|手機版|InPowerS.Net

GMT+8, 2025-4-11 20:58

Powered by Discuz! X3.4

© 2001-2023 Discuz! Team.

快速回復 返回頂部 返回列表