Home > Backend Development > C++ > Why Does My DPI-Unaware Application Suddenly Exhibit UI Distortion After Updating to System Aware?

Why Does My DPI-Unaware Application Suddenly Exhibit UI Distortion After Updating to System Aware?

Barbara Streisand
Release: 2025-01-28 09:06:11
Original
1005 people have browsed it

Why Does My DPI-Unaware Application Suddenly Exhibit UI Distortion After Updating to System Aware?

DPI Awareness: Windows Bitmap Scaling (6.0) vs. System Aware (6.1)

This case study examines an application initially designed as DPI-Unaware, relying on Windows bitmap scaling for high-DPI displays. An update to version 6.1 unexpectedly changed its DPI awareness to System Aware, resulting in UI distortion.

Troubleshooting the Issue

The root cause is a newly included third-party component in the updated version. Despite the application's inherent DPI-Unawareness, the third-party component introduced DPI awareness.

Managing DPI Awareness

DPI awareness can be explicitly controlled within the application manifest:

<code class="language-xml"><application>
  <windowsSettings>
    <dpiAware>false</dpiAware>
  </windowsSettings>
</application></code>
Copy after login

Alternatively, Windows APIs offer programmatic control:

<code class="language-csharp">SetProcessDPIAware();
GetAwarenessFromDpiAwarenessContext(GetWindowDpiAwarenessContext(hWnd));</code>
Copy after login

Solution

To revert to DPI-Unawareness, add <dpiAware>false</dpiAware> to the application manifest. If a third-party component forces DPI awareness, consider adding System.Windows.Media.DisableDpiAwareness to AssemblyInfo.cs to override the unwanted behavior.

The above is the detailed content of Why Does My DPI-Unaware Application Suddenly Exhibit UI Distortion After Updating to System Aware?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template