Make vb.net application DPI aware

大憨熊 提交于 2019-12-02 02:33:24

问题


I need to make my vb.net app scale up properly on any DPI setting. Currently it gets messed up if the setting is anything other than standard.

Everything i found refers either to c# or to older versions of VB or to Visual Studio Pro and are not compatible to the version I am using.

I am on Visual studio express 2013.

Thanks


回答1:


Taken from the article WinForms scaling at large DPI settings – is it even possible? on the Telerik web page

Declaring the DPI awareness is done in a manifest file.
You can use the following markup to set the dpiAware flag. Possible values are True for DPI-aware app, False for non-DPI-aware app and True/PM for per-monitor-DPI-aware app.

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
   <asmv3:application>
        <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
             <dpiAware>true</dpiAware>
        </asmv3:windowsSettings>
   </asmv3:application>
</assembly>

The WinForms platform has its own scaling mechanism which calculates the scaling difference between the system that the form has been designed on and the system it is running on. Then it modifies the size and the location of all controls according to the calculated factor. Note that this scaling will only trigger if your application declares to be DPI-aware, otherwise it will be rendered in the 96 DPI sandbox and the bitmap scaling of the OS will be used.



来源:https://stackoverflow.com/questions/23101791/make-vb-net-application-dpi-aware

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