Our app currently doesn’t support dynamic DPI, which causes issues when it’s launched through RemoteApp on a high DPI screen, resulting in overlapping text and controls.
To solve this problem, we’ve found a workaround for our customers with high DPI displays, which involves changing the HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Control\Terminal Server\WinStations\IgnoreClientDesktopScaleFactor value to 1.
This stops RemoteApp from using DPI scaling, but the downside is that the window size becomes very small. However, if you change the scaling factor on the local PC and then change it back, the window will automatically resize correctly.
Rather than adding an mstsc manifest file to our customers’ PCs, we would like to use the workaround mentioned earlier. However, in order to do so, we need to figure out how to initiate the scaling with the local PC’s settings while avoiding DPI scaling.
2 Answers
Introduction
Dynamic DPI (Dots Per Inch) is a feature that allows the display of an application to adjust to the resolution of the monitor it is being used on. This feature is especially useful for users with high-resolution monitors or those who use multiple monitors with varying resolutions. However, there are instances where supporting dynamic DPI can be problematic, especially for large apps. This article discusses the challenges of supporting dynamic DPI for large apps and provides solutions to overcome them.
Challenges of Supporting Dynamic DPI for Large Apps
Large apps are typically complex, with numerous controls and elements that make up their user interface. Supporting dynamic DPI for such apps can be challenging for several reasons. Firstly, the app’s layout may not be designed to accommodate different DPI settings, resulting in overlapping elements or text. Secondly, the app’s performance may be affected when DPI scaling is enabled, resulting in slow response times or crashes. Finally, supporting dynamic DPI may require significant changes to the app’s code, which can be time-consuming and costly.
To overcome these challenges, developers need to consider several factors when designing or updating large apps. These include the app’s layout, performance, and compatibility with various DPI settings.
Designing an App Layout that Supports Dynamic DPI
To support dynamic DPI, developers need to design an app layout that is flexible enough to accommodate different resolutions. This can be achieved by using scalable controls and elements that adjust their size and position based on the DPI setting. For example, using vector graphics instead of bitmap images ensures that images remain sharp, regardless of the DPI setting.
Developers should also consider the spacing between controls and elements, ensuring that there is enough room for them to expand or contract depending on the DPI setting. Using relative measurements, such as percentages or ems, instead of fixed measurements, such as pixels, can help achieve this.
Optimizing App Performance with Dynamic DPI
Enabling DPI scaling can have a significant impact on an app’s performance, especially if the app is resource-intensive. To optimize app performance when supporting dynamic DPI, developers need to consider several factors.
Firstly, developers should optimize the app’s code to ensure that it is efficient and does not waste resources. This can be achieved by using best practices, such as avoiding unnecessary calculations, reducing memory usage, and minimizing the number of requests.
Secondly, developers should consider using hardware acceleration to improve app performance. This involves offloading some of the app’s processing to the graphics card, which can significantly improve performance when DPI scaling is enabled.
Finally, developers should consider using caching to reduce the amount of processing required when DPI scaling is enabled. This involves caching images, fonts, and other resources, reducing the number of requests required to display the app.
Compatibility with Different DPI Settings
To ensure that an app is compatible with different DPI settings, developers need to test the app on a range of devices with varying resolutions. This can be time-consuming, but it is essential to ensure that the app works correctly for all users.
Developers can also consider using tools, such as the Windows Application Compatibility Toolkit, to help identify compatibility issues and provide solutions to overcome them.
Using Workarounds to Support Dynamic DPI for Large Apps
In some cases, supporting dynamic DPI for large apps may not be feasible or practical. In such cases, developers can consider using workarounds to provide a better user experience.
One workaround is to disable DPI scaling altogether, as described in the article’s introduction. This can be achieved by setting the IgnoreClientDesktopScaleFactor registry key to 1. While this workaround can provide a better user experience, it may not be suitable for all users, especially those with high-resolution displays.
Another workaround is to use a manifest file to specify the app’s DPI awareness. This involves adding a manifest file to the app’s directory, which specifies how the app should behave when DPI scaling is enabled. While this workaround can be effective, it requires additional work to implement and may not be suitable for all apps.
Conclusion
Supporting dynamic DPI for large apps can be challenging, but it is essential to provide a better user experience for users with high-resolution displays. Developers need to consider several factors when designing or updating large apps, including the app’s layout, performance, and compatibility with various DPI settings. Workarounds, such as disabling DPI scaling or using a manifest file, can also be effective in providing a better user experience. By considering these factors and using workarounds where necessary, developers can ensure that their apps are compatible with a range of devices and provide a better user experience for all users.
The issue arises when attempting to use RDP from a high-DPI client monitor to a low-DPI server, as the RDP window fails to scale up and instead represents the screen pixel by pixel, resulting in tiny and unreadable text.
To solve this problem, one can disable HiDPI scaling for mstsc2.exe using AppCompatFlags. However, this is not possible for a system executable, so the proposed solution is to simply create a copy of mstsc.exe and name it mstsc2.exe. To do this, open an elevated (admin) cmd shell and create a copy of mstsc.exe and mstsc.exe.mui, ensuring that the “en-us” part corresponds to the installed language:
cd %systemroot%\system32
copy mstsc.exe mstsc2.exe
cd %systemroot%\system32\en-us\
copy mstsc.exe.mui mstsc2.exe.mui
Then to set the AppCompatFlag
for all users for mstsc2.exe
:
reg add "HKLM\SOFTWARE\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Layers" /t REG_SZ /v "C:\Windows\System32\mstsc2.exe" /d "~ DPIUNAWARE" /f
After following the previous steps, one should now be able to launch mstsc2.exe
and connect to the remote host without encountering any scaling problems.