WinForm:php
int iActulaWidth = Screen.PrimaryScreen.Bounds.Width;html
int iActulaHeight = Screen.PrimaryScreen.Bounds.Height ;post
WPF下的:ui
double dWidth = System.Windows.SystemParameters.PrimaryScreenWidth;url
double dHeight = System.Windows.SystemParameters.PrimaryScreenHeight;spa
double dWidth2 = ActualWidth; //獲取此元素的呈現寬度。若此元素時全屏的,則能夠得到屏幕大小(-_-!!!)orm
double dHeight2 = ActualHeight; //獲取此元素的呈現高度。htm
使用SystemInformation類blog
[csharp]get
//當前的屏幕除任務欄外的工做域大小
string currentScreenSize_OutTaskBar=SystemInformation.WorkingArea.Width.ToString() + "," +SystemInformation.WorkingArea.Height.ToString();
MessageBox.Show("當前的屏幕除任務欄外的工做域大小爲:"+currentScreenSize_OutTaskBar);
//當前的屏幕包括任務欄的工做域大小
string currentScreenSize=System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width.ToString() + "," + System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height.ToString();
MessageBox.Show("當前的屏幕包括任務欄的工做域大小爲:"+currentScreenSize);
//任務欄大小
Size utTaskBarSize = new Size(SystemInformation.WorkingArea.Width, SystemInformation.WorkingArea.Height);
Size ScreenSize = new Size(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width, System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height);
Size TaskBarSize;
TaskBarSize = new Size(
(ScreenSize.Width - (ScreenSize.Width - OutTaskBarSize.Width)),
(ScreenSize.Height - OutTaskBarSize.Height)
);
MessageBox.Show("任務欄大小:" + TaskBarSize.Width + "," + TaskBarSize.Height);