C#如何获取当前机器的显示器像素

Gavin_Y 2010-08-27 10:10:19
现在上级要求做一个工具栏,工具栏的大小限制很严格。
在1024*768的模式下是200像素*30像素
在800*600的模式下是156像素*23像素
这个要如何判断他的当前像素?
...全文
219 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
wuyq11 2010-08-27
  • 打赏
  • 举报
回复
Rectangle rc = new Rectangle();
Console.WriteLine(System.Windows.Forms.Screen.GetBounds(rc).Width);
Console.WriteLine(System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width);
wuyq11 2010-08-27
  • 打赏
  • 举报
回复
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Width;
System.Windows.Forms.Screen.PrimaryScreen.Bounds.Height;
gomoku 2010-08-27
  • 打赏
  • 举报
回复
[Quote=引用 1 楼 gomoku 的回复:]
SystemInformation.PrimaryMonitorSize
[/Quote]
这个不太好,不能应付多显示器的情况。用这个:
Screen.FromRectangle(this.Bounds).Bounds;
dancingbit 2010-08-27
  • 打赏
  • 举报
回复
Screen.PrimaryScreen.Bounds
赤色火焰 2010-08-27
  • 打赏
  • 举报
回复
用Screen.PrimaryScreen.WorkingArea.Width和Screen.PrimaryScreen.WorkingArea.Width获取当前显示器的像素,然后根据这个调整工具栏的Width和Height
gomoku 2010-08-27
  • 打赏
  • 举报
回复
SystemInformation.PrimaryMonitorSize

110,567

社区成员

发帖
与我相关
我的任务
社区描述
.NET技术 C#
社区管理员
  • C#
  • Web++
  • by_封爱
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告

让您成为最强悍的C#开发者

试试用AI创作助手写篇文章吧