Skip to content
This repository has been archived by the owner on May 7, 2024. It is now read-only.

23. High DPI Improvements

Cesar De la Torre edited this page Apr 18, 2018 · 2 revisions

As a traditional business, it's possible that you first wrote your WinForms application on a low resolution monitor. Now that you've invested in the latest 4K monitors, you want your application to look just as nice and function properly without having to do any redesign. Luckily, by making a couple edits to your application you'll be able to do this in just a few minutes.

IMPORTANT NOTE: Make sure that your WinForms app is targeting .NET Framework 4.7 or above, otherwise the improvements will not work. You can install .NET Framework 4.7.1 from:

In the following image you can see how to specify to Visual Studio installer to add .NET Framework 4.7.1:

image

Follow the two simple instructions below to enable High DPI compatibility in your app.

Add and Change the App Manifest

First you'll need to add an app manifest to your WinForms project. To do this you'll want to right click on your project -> Add -> Application Manifest.

Then declare compatibility with Windows 10 by adding the following in your manifest:

  <application>
    <!-- Windows 10 compatibility -->
    <supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
  </application>
</compatibility>

Change the app.config File

Open the _app.config file in your WinForms project and add the following code:

  <add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>

Run the Application

You will now see the improvements and compatibility on your monitor.

NOTE: We are still early in the process of fixing all bug improvements for High DPI compatibility. You may encounter some issues when dragging between screens of different resolutions and/or building on a computer that only supports a lower resolution.

Resources

To read about the the latest improvements that have been made for High DPI compatibility you can check out our blog post here.

Next Steps

Continue on to read about testing our newly modernized application. Test the application

Clone this wiki locally