Home >Backend Development >C++ >How Can I Configure My Applications for Optimal High DPI Display Settings?
High DPI (number per inch) settings of modern display can improve the visual experience. However, applications may encounter problems when rendering text and keeping a clear appearance at a higher resolution. This guide provides a comprehensive plan to solve these problems.
Windows uses different zoom methods at more than 100%DPI. To achieve custom DPI processing, it is necessary to add
to the application list to explicitly enable "DPI virtualization".
<dpiaware>
Add DPI list
Create a new XML file called "App.manifest" in the project directory.
<code class="language-xml"><?xml version="1.0" encoding="utf-8"?> <assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3"> <assemblyIdentity name="MyApplication.app" version="1.0.0.0"/> <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> <application> <windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings"> <dpiAware>true</dpiAware> </windowsSettings> </application> </assembly></code>
or, you can use the function in C#for programming control:
Visual Studio 2015 and above versions SetProcessDPIAware()
<code class="language-csharp">[STAThread] static void Main() { if (Environment.OSVersion.Version.Major >= 6) SetProcessDPIAware(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Form1()); // 根据需要修改 } [System.Runtime.InteropServices.DllImport("user32.dll")] private static extern bool SetProcessDPIAware();</code>For projects that target Visual Studio 2015 UPDATE 1 or higher versions, the list has included the necessary DPI processing instructions. Just delete the comment to activate it.
The above is the detailed content of How Can I Configure My Applications for Optimal High DPI Display Settings?. For more information, please follow other related articles on the PHP Chinese website!