C#獲取屏幕的寬度和高度


//1、在屏幕的右下角顯示窗體
//這個區域不包括任務欄的
Rectangle ScreenArea = System.Windows.Forms.Screen.GetWorkingArea(this);
//這個區域包括任務欄,就是屏幕顯示的物理范圍
Rectangle ScreenArea = System.Windows.Forms.Screen.GetBounds(this);
int width1 = ScreenArea.Width; //屏幕寬度 int height1 = ScreenArea.Height; //屏幕高度
this.Location = new System.Drawing.Point(width1 - 窗體寬度, height1 - 窗體高度); //指定窗體顯示在右下角
//2、在母窗體的中間顯示子窗體的位置計算
waitForm.Location = new Point((this.Location.X + (this.Width - waitForm.Width) / 2),
(this.Location.Y + (this.Height - waitForm.Height) / 2));Web下:System.Web.HttpBrowserCapabilities hbc=new System.Web.HttpBrowserCapabilities();




Demo

Rectangle ScreenArea = Screen.GetWorkingArea(this);
this.Size = new Size(100,ScreenArea.Height);//設置為屏幕高度


免責聲明!

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



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