Click here to Skip to main content
15,881,938 members
Articles / All Topics

How to Make the Windows Desktop Application Work Well on High-DPI Displays and Fix Blurry Fonts

Rate me:
Please Sign up or sign in to vote.
4.51/5 (13 votes)
26 Nov 2015CPOL1 min read 12.4K   4   2
How to make the Windows Desktop Application work well on High-DPI displays and fix blurry fonts

If you change the DPI of your machine from 100% to any other higher value, your desktop applications may appear somewhat blurry when you compare them with other applications on the screen. Alternately, display problems may exist such as truncated text.

Image 1

In order to fix this issue, you would need to disable DPI virtualization for the application. To do this, right-click the application’s shortcut and then click Properties. On the Compatibility tab, select Disable Display Scaling on High DPI Settings, and then click OK.

Image 2

Alternatively, you may also disable this setting using the below Registry keys.

Registry key: HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

String: “Path to your application exe”

Value: ~ HIGHDPIAWARE

Please note there is a space between ‘tilde’ and ‘HIGHDPIAWARE’.

Image 3

There are number of ways to set a value in the registry. The below steps will show the process to set this value in registry using Inno setup:

var
str_MyAppFullExePath: String;

str_MyAppFullExePath := ExpandConstant('{app}') ;

RegWriteStringValue(HKEY_LOCAL_MACHINE, 
'SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', str_MyAppFullExePath + 
'\' + '{#MyAppExeName}' , '~ HIGHDPIAWARE');

Possible Issues

If your application is 32 bit, then the above command will set the value at:

HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node
\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

instead of:

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers

This will not set the “Disable Display Scaling on High DPI Settings” property. This can be fixed by using the below command:

if IsWin64 then
 begin
	RegWriteStringValue(HKLM64, 'SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', 
	str_MyAppFullExePath + '\' + '{#MyAppExeName}' , '~ HIGHDPIAWARE');
 end
 else
 begin
	RegWriteStringValue(HKEY_LOCAL_MACHINE, 
	'SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers', 
	str_MyAppFullExePath + '\' + '{#MyAppExeName}' , '~ HIGHDPIAWARE');
 end ;

It will force the setup to store value in 64 bit registry.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer
India India
For more technical articles please visit my blog at-
http://komalmangal.blogspot.in

Comments and Discussions

 
GeneralMy vote of 5 Pin
Santhakumar M4-Dec-15 8:06
professionalSanthakumar M4-Dec-15 8:06 
GeneralMy vote of 5 Pin
URVISH_SUTHAR126-Nov-15 22:58
URVISH_SUTHAR126-Nov-15 22:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.