Windows 窗体应用程序在 Windows 7 上比例不佳
我有一个使用 VS2008(以前从 C# 1.1 移植)构建的 C# 3.0 Windows 窗体应用程序,它在 WinXP 32 位 PC 上看起来不错,但在 Win7 64 位笔记本电脑上比例却很高。
我发现有关应用程序使用的 Win7 缺乏对 Tahoma 8 支持的参考。我是否需要使用 Tahoma 9 重新设计对话框才能使其在所有 3 个操作系统上都能正常显示?
以下是我对包含单选按钮和按钮的组框的初始测量值(厘米):
操作系统、分辨率、GroupBox HxW、RadioButton HxW
XP、1024 x 768、7.5 x 6.75、0.75 x 4.4
7、1024 x 768、6.8 x 6.3、0.8 x 5.0
7、1680 x 1050、4.9 x 4.5 , 0.55 x 3.5
问题基本上是在不同的操作系统上,组框的比例变化与它的无线电不同。包含,使得在 XP 中适合组框的单选按钮和标签在 7 上超出范围(x 和 y 轴)。同样,按钮上的文本比按钮增长得更多。即使我将 7 盒子的分辨率调低以匹配 XP 盒子,也会发生这种情况。 GroupBox 的字体比收音机的字体大,但即使我使它们相等,我也没有看到任何改进。
我认为这与应用程序最初是用旧版本的 C# 创建然后移植的事实有关。我这样说是因为我刚刚使用 VS2008 创建了一个新的(空)Windows 窗体项目,对于我的应用程序中在 win7 上无法正确显示的每个控件,当我将该控件复制到新应用程序并在 win7 上运行它时,它会调整大小正确。应用程序中必须有一些控件继承的高级属性。
造成这种情况的原因是什么?我该怎么办?
提前致谢。
I've got a C# 3.0 Windows Forms app built with VS2008 (previously ported from C# 1.1) that looks fine on a WinXP 32bit PC but has jacked proportions on Win7 64bit laptop.
I'm finding references to the lack of support on Win7 for Tahoma 8, which the app uses. Do I need to redesign my dialog using Tahoma 9 to get it to display well on all 3 OSes?
Here are my initial measurements (cm) of a group box containing radio buttons and a button:
OS, Resolution, GroupBox HxW, RadioButton HxW
XP, 1024 x 768, 7.5 x 6.75, 0.75 x 4.4
7, 1024 x 768, 6.8 x 6.3, 0.8 x 5.0
7, 1680 x 1050, 4.9 x 4.5, 0.55 x 3.5
The problem is basically that on the different OS's, the group box has its proportions changed differently than the radios it contains, such that radios and labels that fit fine in the group box in XP run out of bounds (both x & y axis) on 7. Similarly, the text on the button grew more than the button. This happens even when I dial down the 7 box's resolution to match the XP box. The GroupBox's font is larger than that of the radios, but even when I made them equal I saw no improvement.
I think it has something to do with the fact that the application was originally created with an older version of C# and then ported. I say this because I just created a new (empty) Windows forms project using VS2008, and for every control in my app that isn't displaying correctly on win7, when I copy that control to the new app and run it on win7 it resizes correctly. There must be some high level property in the app that the controls are inheriting.
What causes this and what can I do about it?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
主窗体的“AutoScaleMode”设置为“Font”。将其设置为“DPI”修复了它(尽管由于代码未预期在启动时调整大小而产生了其他问题...空引用,但我可以处理这些问题)。
Tergiver 获得了双重荣誉,因为他向我指出了表单的属性表,并且让我花了这么长时间才注意到明显的属性:)
The main form's 'AutoScaleMode' was set to 'Font'. Setting it to 'DPI' fixed it (although that created other problems due to the code not anticipating being resized on startup...null refs, but I can deal with those).
Tergiver gets double credit for pointing me to the form's property sheet and for me taking this long to notice the obvious property :)