We have a control inside a WinForm (CefSharp control) that suffers from graphical artifacts when a users screen is set to 125% on windows. Its not just the control, stand alone Chrome does it to an extent. The only way we have been able to fix the artifacts is by changing the exe setting pictured below. Is there a way to change it in code?
edit: This is not a duplicate. As making an app DPI aware is not the same as DPI scaling heavior
Right-click the application, select Properties, select the Compatibility tab, and then select the Disable display scaling on high DPI settings check box.
DPI-scaling overrides This forces the process to run in per-monitor DPI awareness mode. This setting was previously referred to as “Disable display scaling on high-DPI settings.” This setting effectively tells Windows not to bitmap stretch UI from the exe in question when the DPI changes. System.
Here, you will have to untick an option which says 'Disability Full-screen optimization' and tick on 'Override High DPI Scaling behavior'. As you select 'Apply', there will be an instant boost in your gaming experience and you get more FPS. Though this might sound like a very basic hack, it does bring a difference.
This option was previously known as “Disable display scaling on high DPI settings”, and it does the same thing. System: Windows will use its normal behavior. Applications that don't respect system DPI settings will be “bitmap stretched” to appear larger so they're more easily readable, but will often appear blurry.
Way 1. How Override high DPI scaling (check checkbox) with registry
Start up Registry Editor and navigate to this key:
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers
Now add a string value (REG_SZ) whose name is the full path to the application executable and whose value is HIGHDPIAWARE
Code example:
string appPath = string.Format(@"{0}\{1}.exe", My.Application.Info.DirectoryPath, My.Application.Info.AssemblyName);
My.Computer.Registry.SetValue(@"HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers", appPath, "HIGHDPIAWARE");
Read more: High DPI Settings in Windows
Way 2. How to change DPI-aware in assembly manifest?
DPI-aware applications are not affected by the OS. Such applications render themselves to fit the actual DPI of a screen and provide a much better visual experience.
Add the <dpiAware>
element to the manifest code and set its value to true
.
<?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="1.0.0.0" name="MyApplication.app"/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<asmv3:application>
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
Additional resources:
High DPI Support
High DPI Desktop Application Development on Windows (also Application Manifests)
DPI Awareness - Unaware in one Release, System Aware in the Other [duplicate]
Writing High-DPI Aware Windows Apps
Writing DPI-Aware Desktop and Win32 Applications
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With