您的位置:首页 > 编程语言 > C#

C#获取屏幕大小或任务栏大小

2012-10-23 10:06 316 查看
使用SystemInformation类

//当前的屏幕除任务栏外的工作域大小

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 OutTaskBarSize = 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# 工作 string