C# 获取屏幕的大小 SystemInformation类
2015-03-11 09:44
246 查看
C# 获取屏幕的大小
WinForm:
int iActulaWidth = Screen.PrimaryScreen.Bounds.Width;
int iActulaHeight = Screen.PrimaryScreen.Bounds.Height ;
WPF下的:
double dWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
double dHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
double dWidth2 = ActualWidth; //获取此元素的呈现宽度。若此元素时全屏的,则可以获得屏幕大小(-_-!!!)
double dHeight2 = ActualHeight; //获取此元素的呈现高度。
使用SystemInformation类
[csharp]
//当前的屏幕除任务栏外的工作域大小
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);
WinForm:
int iActulaWidth = Screen.PrimaryScreen.Bounds.Width;
int iActulaHeight = Screen.PrimaryScreen.Bounds.Height ;
WPF下的:
double dWidth = System.Windows.SystemParameters.PrimaryScreenWidth;
double dHeight = System.Windows.SystemParameters.PrimaryScreenHeight;
double dWidth2 = ActualWidth; //获取此元素的呈现宽度。若此元素时全屏的,则可以获得屏幕大小(-_-!!!)
double dHeight2 = ActualHeight; //获取此元素的呈现高度。
使用SystemInformation类
[csharp]
//当前的屏幕除任务栏外的工作域大小
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);
相关文章推荐
- C# 获取屏幕的大小
- C#Winform获取屏幕大小
- C#获取屏幕大小或任务栏大小
- C#获取屏幕分辨率(大小)
- c#获取当前屏幕大小
- C#获取当前屏幕大小或任务栏的大小,不用API
- C# 获取屏幕的大小
- C#获取当前屏幕大小或任务栏的大小
- C#获取当前屏幕大小或任务栏的大小,不用API.
- C#Winform获取屏幕大小
- C#Winform获取屏幕大小
- C# 获取屏幕的大小
- c#获取当前屏幕大小
- C#获取屏幕大小或任务栏大小
- C# 获取屏幕的大小
- C#获取屏幕大小或任务栏大小
- C# WinForm 获取屏幕分辨率大小
- C#获取屏幕大小的“简单整理”。。
- C#获取屏幕分辨率(大小)
- JS获取浏览器窗口大小 获取屏幕,浏览器,网页高度宽度