Handling dynamic display scaling
|
<< Click to Display Table of Contents >> Navigation: Gnostice Document Studio .NET > Going Deeper > Document Viewing > WinForms > Handling dynamic display scaling |
Windows allows text and other UI elements to be scaled by changing the DPI setting. Correctly designed desktop applications handle this change by resizing their UI appropriately. This automatic scaling enables a form and its controls, designed on one machine with a certain display resolution or system font, to be displayed appropriately on another machine with a different display resolution or system font. It assures that the form and its controls will intelligently resize to be consistent with native windows and other applications on both the users' and other developers' machines.
For the most part automatic scaling works as expected in .NET Framework version 2.0 and later. However font scheme changes can sometimes be problematic. So when automatic scaling is enabled the document viewer control may not work as expected. To overcome this issue we need to configure the project for High DPI support. Below are the steps to achieve this.
1.Right click on the project, click on Add, then select New Item.Then select Application Manifest File.
2.Add the below settings to the manifest file to declare compatibility with Windows 10. If the setting is already present in the manifest file, then uncomment it according to the OS version.
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
|
3.Then enable per-monitor DPI awareness by adding the below settings. If the setting is already present in the manifest file, then uncomment it.
<application xmlns="urn:schemas-microsoft-com:asm.v3">
|
4.Set the ‘AutoScaleMode’ to None in the designer class.
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.None;
|