界面随电脑分辨率真自动调整

bin394971197 2010-09-18 12:47:33
C#做的一个程序界面,当分辨率为8000*600时,显示不完整,分辨率太大了时,又留出很多空白。

有些文本当界面缩小时,也挤到一块去了。像这种情况应该是比较普遍的,应该怎么解决呢。

我们用播放器看电影时,就可以自由缩放而不会影响到电视的画面,为什么程序就不可以。

...全文
392 13 打赏 收藏 转发到动态 举报
写回复
用AI写文章
13 条回复
切换为时间正序
请发表友善的回复…
发表回复
allen0118 2011-11-07
  • 打赏
  • 举报
回复
Screen.PrimaryScreen.Size
MKing0412 2011-11-07
  • 打赏
  • 举报
回复
让我看下你的using指令和引用。 谢谢
[Quote=引用 5 楼 daxinghuangdi 的回复:]

//检查当前计算机的显示情况,便于调节窗体
private void CheckUserScreenArea()
{
//检查屏幕分辨率
if (Screen.GetWorkingArea(this).Width < 1024 | Screen.GetWorkingArea(this).Height < 768)
{
//……
[/Quote]
wedding123 2011-11-07
  • 打赏
  • 举报
回复
DOCK即可
火星大能猫 2011-11-07
  • 打赏
  • 举报
回复
一般设置anchor就可以了
RobinLi_VIP 2011-11-07
  • 打赏
  • 举报
回复
来看看一下!
daxinghuangdi 2010-09-27
  • 打赏
  • 举报
回复

//检查当前计算机的显示情况,便于调节窗体
private void CheckUserScreenArea()
{
//检查屏幕分辨率
if (Screen.GetWorkingArea(this).Width < 1024 | Screen.GetWorkingArea(this).Height < 768)
{
//MessageBox.Show("您的显示器分辨率过低或者可用的桌面区域过小,本程序可能无法显示完全。\r\n推荐调整至1024x768或更高分辨率,或调节Windows开始菜单栏的宽度以增加可用桌面显示区域。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning);
this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
this.MinimumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
this.Width = Screen.GetWorkingArea(this).Width;
this.Height = Screen.GetWorkingArea(this).Height;
this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2;

}
else
{
this.MaximumSize = new Size(Screen.GetWorkingArea(this).Width, Screen.GetWorkingArea(this).Height);
this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight);
this.Width = Screen.GetWorkingArea(this).Width;
this.Height = Screen.GetWorkingArea(this).Height;
this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2;

}
if ((Screen.GetWorkingArea(this).Width >= Program.NormalFormWidth) && (Screen.GetWorkingArea(this).Height >= Program.NormalFormHeight))
{
this.MaximumSize = new Size(Program.MaxFormWidth, Program.MaxFormHeight);
this.MinimumSize = new Size(Program.MinFormWidth, Program.MinFormHeight);
this.Width = 1024;//Program.NormalFormWidth;
this.Height = 768;//Program.NormalFormHeight;
this.Top = Screen.GetWorkingArea(this).Height / 2 - this.Height / 2;
this.Left = Screen.GetWorkingArea(this).Width / 2 - this.Width / 2;
}
}
Evil 2010-09-27
  • 打赏
  • 举报
回复
2楼正解!
在设置宽度时采用百分比就可以了。
完美算法 2010-09-27
  • 打赏
  • 举报
回复
给楼主的建议:
1、用滚动条,界面显得不友好;
2、建议控件设置dock的属性;
3、如果控件太多,最好归类放在容器中;
wuyq11 2010-09-27
  • 打赏
  • 举报
回复
使用dock,设置Acchor属性
判断分辨率
在不同分辨率下调整控件坐标
窗体加载resize时改变坐标

bin394971197 2010-09-27
  • 打赏
  • 举报
回复
谢谢各位了,因为系统当中有不少用控件做的菜单,不太好弄,就直接加上滚动条解决了。
q107770540 2010-09-18
  • 打赏
  • 举报
回复
用百分比代替规定值
WTPMCheng 2010-09-18
  • 打赏
  • 举报
回复
"当分辨率为8000*600时"

LZ你有8000的分辨率吗?

你可以控制界面的大小,根据屏幕的大小。
feixuyue 2010-09-18
  • 打赏
  • 举报
回复
Screen.PrimaryScreen.Size //屏幕大小

111,129

社区成员

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

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

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