Windows forms & High DPI

Having a high resolution monitor is cool but not if you are developing Windows forms applications. The default settings on the Visual Studio Windows forms run the application like this.

No so good now is it?
After some searching I managed to find a fix. Here it is.

First add a Application Manifest file to you project

Project right click ➡ Add New Item ➡ Application Manifest

It will add a file like this to your project

You can either edit the file to look this by removing comment tags or just copy paste code and change according to your project structure.

<?xml version=”1.0" encoding=”utf-8"?>
<assembly xmlns=”urn:schemas-microsoft-com:asm.v1" manifestVersion=”1.0" xmlns:asmv3=”urn:schemas-microsoft-com:asm.v3" >
<assemblyIdentity version=”" name=””/>
<trustInfo xmlns=”urn:schemas-microsoft-com:asm.v2">
<requestedPrivileges xmlns=”urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level=”asInvoker” uiAccess=”false” />
<asmv3:windowsSettings xmlns=””>

And here is the output

You can also pinvoke SetProcessDPIAware() in your Main() method,

static void Main() {
if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware();
Application.Run(new Form1()); // Edit as needed
private static extern bool SetProcessDPIAware();

Happy Coding!