Spread Windows Forms 9.0 Product Documentation
Adding Support for High DPI Settings

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.5.2.

  1. Add code such as the following to the application manifest.
    Code
    Copy Code
    <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3" >
      <asmv3:application>
        <asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
          <dpiAware>true</dpiAware>
        </asmv3:windowsSettings>
      </asmv3:application>
    </assembly>
    
  2. Use the Windows API with the following code.
    Code
    Copy Code
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [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();
    }
    

    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.

  3. Enable Windows Forms High DPI support by adding code to the App.config.
    Code
    Copy Code
    <?xml version="1.0" encoding="utf-8" ?>
    <configuration>
      <appSettings>
        <add key="EnableWindowsFormsHighDpiAutoResizing" value="true" />
      </appSettings>
    </configuration>
    

 

 


Copyright © GrapeCity, inc. All rights reserved.

Support Options | Documentation Feedback