Skip to main content

WindowsFormsSettings.SetPerMonitorDpiAware() Method

Enables “Per-Monitor (v2)” DPI awareness mode for the process if it runs on versions greater than Windows 10 Creators Update (build 1703). On older Windows OS versions, enables system DPI awareness mode.

Namespace: DevExpress.XtraEditors

Assembly: DevExpress.Utils.v23.2.dll

NuGet Packages: DevExpress.Utils, DevExpress.Wpf.Core

Declaration

public static void SetPerMonitorDpiAware()

Remarks

Call this method on the application startup.

static class Program {
    /// <summary>
    /// The main entry point for the application.
    /// </summary>
    [STAThread]
    static void Main() {
        WindowsFormsSettings.SetPerMonitorDpiAware();
        //...
        Application.Run(new Form1());
    }
}

To ensure the DPI awareness mode is correctly set up and activated, we recommend to use the DevExpress Project Settings Page.

The SetPerMonitorDpiAware method can apply different DPI awareness modes depending on the Windows version (to check your version, press the “Ctrl+R” hotkey and type “winver”).

  • On Windows 10, version 1607 and later, the SetPerMonitorDpiAware method enables “Per-Monitor (v2)” DPI awareness mode by calling the SetProcessDpiAwarenessContext WinApi function.

  • On older Windows OS versions, the SetPerMonitorDpiAware method enables system DPI-awareness (this method is equivalent to the WindowsFormsSettings.SetDPIAware method in this case).

See Graphics Performance and High DPI and High DPI Desktop Application Development on Windows for information on DPI awareness modes.

The following code snippets (auto-collected from DevExpress Examples) contain references to the SetPerMonitorDpiAware() method.

Note

The algorithm used to collect these code examples remains a work in progress. Accordingly, the links and snippets below may produce inaccurate results. If you encounter an issue with code examples below, please use the feedback form on this page to report the issue.

See Also