2025年3月14日 星期五 甲辰(龙)年 月十三 设为首页 加入收藏
rss
您当前的位置:首页 > 计算机 > 编程开发 > .net

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

时间:12-12来源:作者:点击数:18
CDSY,CDSY.XYZ

使用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);

 

CDSY,CDSY.XYZ
方便获取更多学习、工作、生活信息请关注本站微信公众号城东书院 微信服务号城东书院 微信订阅号
推荐内容
相关内容
栏目更新
栏目热门
本栏推荐