[]
Spread supports high DPI settings provided that the application has high DPI support enabled.
Refer to Microsoft's web site for more information about enabling DPI support for your application.
You can refer to the following steps for a general example of how to enable DPI support in .NET 4.6.2.
Use the Windows API with the following code.
static class Program
{
/// <p>DOC-SUMMARY-TAG-OPEN</p>
/// The main entry point for the application.
/// <p>DOC-SUMMARY-TAG-CLOSE</p>
[STAThread]
static void Main()
{
SetProcessDPIAware();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new MainForm());
}
[System.Runtime.InteropServices.DllImport("user32.dll")]
public extern static IntPtr SetProcessDPIAware();
}
!type=note
Note: The SetProcessDPIAware API must be called before any window is created; otherwise, a window created before using this API will have the wrong size and font.
Add Spread code:
//add code in InitializeComponent() of cs file
this.fpSpread1.SpreadScaleMode = FarPoint.Win.Spread.ScaleMode.ZoomDpiSupport;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;
Enable Windows Forms High DPI support by adding code to the App.config.
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
</appSettings>
</configuration>
Use the following steps to enable DPI support.
Install the .NET 4.7 Framework.
Create a new windows forms application.
Add an App.config with the following information to the root directory of the form (same directory as Program.cs).
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.7"/>
</startup>
<System.Windows.Forms.ApplicationConfigurationSection>
<add key="DpiAwareness" value="PerMonitorV2"/>
<!-- Uncomment each value to disable the fixes one by one. -->
<!--
<add key="Form.DisableSinglePassScalingOfDpiForms" value="true"/>
<add key="ToolStrip.DisableHighDpiImprovements" value="true"/>
<add key="CheckedListBox.DisableHighDpiImprovements" value="true"/>
<add key="MonthCalendar.DisableHighDpiImprovements" value="true"/>
<add key="AnchorLayout.DisableHighDpiImprovements" value="true"/>
<add key="DataGridView.DisableHighDpiImprovements" value="true"/>
-->
</System.Windows.Forms.ApplicationConfigurationSection>
</configuration>
Add an App.manifest with the following information to the root directory of the form (same directory as Program.cs).
<?xml version="1.0" encoding="utf-8"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1">
<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">
<!-- UAC Manifest Options
If you want to change the Windows User Account Control level replace the
requestedExecutionLevel node with one of the following.
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
Specifying requestedExecutionLevel element will disable file and registry virtualization.
Remove this element if your application requires this virtualization for backwards
compatibility.
-->
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!-- A list of the Windows versions that this application has been tested on and is
is designed to work with. Uncomment the appropriate elements and Windows will
automatically selected the most compatible environment. -->
<!-- Windows 10 -->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}" />
</application>
</compatibility>
<!--<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true</dpiAware>
</windowsSettings>
</application>-->
</assembly>
Verify that Program.cs has the following settings.
static class Program
{
/// <p>DOC-SUMMARY-TAG-OPEN</p>
/// The main entry point for the application.
/// <p>DOC-SUMMARY-TAG-CLOSE</p>
[STAThread]
static void Main()
{
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
Check that Form1.designer.cs has the following settings.
this.fpSpread1.SpreadScaleMode = FarPoint.Win.Spread.ScaleMode.ZoomDpiSupport;
this.AutoScaleDimensions = new System.Drawing.SizeF(96F, 96F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Dpi;