Why are my dialog boxes too small on some (but not all) Windows7 computers?

十年热恋 提交于 2019-12-04 03:11:06

问题


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

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%.

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.

Edit

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.

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

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

/Edit

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


回答1:


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.

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.

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




回答2:


I had the same issue when a Win 7 user adjusted the default font size in "Control Panel\All Control Panel Items\Display"

When you have forms set to "Fixed Dialog" set the following properties on your form: .AutoScaleMode=Font .AutoSize=True .AutoSizeMode=GrowOnly so windows can resize your form based on the sizes of the child elements.




回答3:


Display size, resolution, DPI, large fonts, small fonts are some possible causes.



来源:https://stackoverflow.com/questions/6983569/why-are-my-dialog-boxes-too-small-on-some-but-not-all-windows7-computers

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!