1. 程式人生 > 其它 >C#獲取螢幕的寬度和高度

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

轉載:https://www.cnblogs.com/zhangruifeng/p/5958010.html

C#獲取螢幕的寬度和高度//1、在螢幕的右下角顯示窗體

//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();

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