C#獲取屏幕工作區大小


做Winform或WPF程序時,有時需要獲取當前系統屏幕的大小(含任務欄或不含任務欄),具體方法如下:

1. 引入System.Windows.Forms命名空間;

2. 獲取含任務欄的屏幕大小:

var h = Screen.PrimaryScreen.Bounds.Height;
var w = Screen.PrimaryScreen.Bounds.Width;

3. 獲取不含任務欄的屏幕大小:

var h = SystemInformation.WorkingArea.Height;
var w = SystemInformation.WorkingArea.Width;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM