- 积分
- 73649
- 明经币
- 个
- 注册时间
- 2001-6-7
- 在线时间
- 小时
- 威望
-
- 金钱
- 个
- 贡献
-
- 激情
-
|
作者:kean
原文地址:http://through-the-interface.typepad.com/through_the_interface/2011/03/handling-dpi-scaling-in-your-net-applications-forms.html
This topic isn’t at all specific to AutoCAD – in fact it was encountered by Adam Nagy with the recent Plugin of the Month he developed for Revit – but it seemed something people might hit. Thanks to Adam for proposing this topic and providing the information to share with everyone. :-)
In recent versions of Windows – at least with Vista and Windows 7, but perhaps versions before that – it’s possible for the user to adjust DPI Scaling options on their system as part of the usability/accessibility options. This can cause issues with how your dialogs are displayed, as sometimes the contents are scaled beyond the size of the dialog itself.
On Vista it’s this setting is accessible via Control Panel –> Ease of Access –> Optimize visual display (or Personalization –> Adjust font size (DPI), if in Classic View):
The DPI settings can be modified in the following dialog:
On Windows 7, things look a little different (I don’t have a Windows 7 machine, so am using a screenshot of Adam’s for this):
As mentioned, the problem can potentially arise that DPI scaling leads to dialog content scaling beyond the dialog’s limits. When the setting was at 150% Win7, Adam’s Revit plugin’s main form was cropped at the bottom.
I will admit, despite my efforts to reproduce this behaviour in a standalone application on Windows Vista, I have not been able to. A comparable dialog looks like this at 96 and 120 DPI, respectively:
[url=http://through-the-interface.typepad.com/.a/6a00d83452464869e2014e86a5b890970d-pi][/url]
Obviously neither are cropped, but presumably scaling further – and perhaps the fact the plugin is hosted in Revit rather than standalone – can cause unwanted content cropping.
The solution Adam found was to edit the form’s properties, to make sure it a) AutoSized and b) used the Dpi AutoScaleMode:
This scenario was new to me, but I do suggest testing your applications with the DPI scaling set to 150%, to make sure it doesn’t cause a problem for your GUI.
A quick tip that saved me time during my failed efforts to reproduce the erroneous behaviour: after changing the setting you can simply log out rather than performing a full reboot (as was recommended by Vista, at least).
|
本帖子中包含更多资源
您需要 登录 才可以下载或查看,没有账号?注册
x
|