为什么在某些(但不是全部)Windows7计算机上,我的对话框太小? [英] Why are my dialog boxes too small on some (but not all) Windows7 computers?

查看:116
本文介绍了为什么在某些(但不是全部)Windows7计算机上,我的对话框太小?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我开始在Windows 7上测试Winforms(使用VS2008)应用程序,并且遇到一个奇怪的问题。

I'm starting to test a Winforms (using VS2008) app on Windows 7, and am seeing a strange problem.

在前几个版本上运行良好Win7安装,但在接下来的两个中,我的许多对话框都太小,将内容削减了约30%。

It ran fine on the first couple of Win7 installations, but on the next two, many of my dialogs are too small, clipping the content by about 30%.

该应用程序是在WinXP上开发的,尚未安装在XP安装的任何上都看到了这个问题!

The app was developed on WinXP, and have not seen this problem on any of the XP installations!

只是开始研究问题-没有关于系统之间差异的任何详细信息

Just starting to investigate the problem - don't have any details on differences between the systems that work and those that don't yet.

编辑

凯特(Kate)对答案之一的评论,当安装新显示器时,Win7有时会更改为自定义文本大小。出现问题的机器具有宽屏大显示器,当我们检查(控制面板+显示+自定义文字大小)时-足够确定-自定义文字大小设置为125%。将其设置为100%可以解决问题。

According to Kate's comment to one of the answers, Win7 will sometimes change to a custom text size when a new monitor is installed. The machine with the problem has a big, widescreen monitor, and when we checked (Control Panel + Display + Custom Text Size) - sure enough - the custom text size was set to 125%. Setting it to 100% made the problem go away.

然后我可以通过将文本大小设置为125%在WinXP上复制该问题。

I was then able to replicate the problem on WinXP by setting the text size to 125%.

所以现在的问题变成了-如何确保Winforms应用程序独立于自定义文本大小?

So the question now becomes - how do you ensure a Winforms app is "custom text size independent"?

/编辑

根据建议,以下是一些屏幕截图。第一个来自Windows 7计算机,第二个来自我的WinXP开发系统。

As suggested, here are some screen shots. 1st one is from a Windows 7 computer, 2nd one is from my WinXP development system.

推荐答案

尽管屏幕DPI和主题都可以更改控件的大小,但这不是问题,因为在屏幕截图的窗口镶边和非文本控件的大小均保持不变。问题是您没有考虑自定义字体大小。

Although both screen DPI and Themes can change the size of controls, that is not the problem here because in your screen shots the window chrome and non-text control sizes are unchanged. The problem is you are not taking custom font sizes into account.

如果要移动控件以将其固定为固定的表单大小,则必须使用控件的 Control.AutoScaleDimensions 属性。

If you wanted to move controls around to fix them into a fixed form size you would have to perform calculations using the Control.AutoScaleDimensions property of your controls. That is a lot of work, don't do that.

相反,请使用绝对坐标对控件进行布局,并放大表格以包含结果。设置表单的 AutoScaleMode = AutoScaleMode.Font

Instead, lay out your controls using absolute coordinates and enlarge your form to contain the results. Set your forms' AutoScaleMode = AutoScaleMode.Font.

这篇关于为什么在某些(但不是全部)Windows7计算机上,我的对话框太小?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆