明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 445|回复: 0

Handling DPI scaling in your .NET application’s forms

[复制链接]
发表于 2011-3-12 07:39 | 显示全部楼层 |阅读模式
作者: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
"觉得好,就打赏"
还没有人打赏,支持一下

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-5-18 12:34 , Processed in 0.348200 second(s), 31 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表