DPI Support

UI for WinForms is giving your Windows apps a new power today - support for high resolution DPI monitors is now a built-in part of UI for WinForms.

In R2 2017 we are introducing built-in HDPI support in the Progress® Telerik® UI for WinForms suite. This coincides with the HDPI improvements Microsoft is bringing with .NET 4.7 and the Windows 10 Creators Update. The best part is that you will get this support no matter which .NET framework you are targeting (currently supported from .NET 2.0 and up).

All you will have to do is declare your application as DPI aware and RadControls will scale their UI elements in accordance to the current DPI settings automatically. To do that, you have to have an app.manifest file and/or an app.config file with several lines of code. You can see examples of that in our previous blog post on the High DPI in WinForms matter and in this Microsoft blog post. We will look into the technical details further down this article.

With the changes we are introducing, the common problem of bad scaling when your applications run on high resolution monitors goes away, so your app will ship with higher quality on more systems instantly. The problem with the blurry fonts and unreadable texts will be eliminated and the potential of modern hardware will be utilized fully.

Although it is a bit tricky to demonstrate HDPI support with a single image, here is an example with screenshots of the same application on two different monitors. You will notice that the first image will become blurry unlike the second one.

Resolution: 3840 x 2160 - Scaling: 250%
dpi-support 001
dpi-support 002

How to Enable HDPI Support in Your Application

In R3 2017 we introduced the EnableDpiScaling property that allows you to enable/disable this on a global level. This is a static property of RadControl and must set before any controls are initialized. For example in the form's constructor.

In R2 2020 SP1 we introduced the EnableImageDpiScaling property indicating whether the RadControls scaling logic will be used to resize the images when the application is run in a high DPI environment. This is a static property of RadControl and must set before any controls are initialized. For example in the form's constructor.

Here are the two ways you can make your application DPI aware:

The first way is to add an app.manifest file to your project. In that manifest file add the following XML:

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1"
                xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
  <assemblyIdentity version="" name="MyApplication.app"/>

    <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">

  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
      <!-- A list of all Windows versions that this application is designed to work with. 
      Windows will automatically select the most compatible environment.-->
      <!-- Windows 10 -->
      <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
      <!-- Windows 8.1 -->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
      <!-- Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!-- Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!-- Windows 8 -->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>


Applications not manifested for Windows 8.1 or Windows 10 will return the Windows 8 OS version value (6.2). It is mandatory to manifest your applications for Windows 8.1 or Windows 10. Please refer to Targeting your application for Windows.

Note that declaring DPI awareness in the app.manifest file breaks ClickOnce applications. The suggested way to avoid this brings us to the second option, which is only available if your project's target framework is .NET 4.7 and your application run on a Windows 10 Creators update (1703). It requires you to have an app.manifest and an app.config files added to your project. Inside the config file you should have the following settings:

<?xml version="1.0" encoding="utf-8"?>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
    <add key="DPIAwareness" value="PerMonitorV2"/>
    <add key="DisableDpiChangedMessageHandling" value="True" />

and inside the manifest file you should declare your app is compatible with Windows 10:

<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<assemblyIdentity version="" name="MyApplication.app"/>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
   <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />

It is necessary to set the AutoScaleMode property for all RadForms to AutoScaleMode.None because they handle their own scaling. It is not needed the automatic Windows scaling to be performed.

See Also

In this article
Not finding the help you need? Improve this article