Back to Devexpress

Graphics Performance and High DPI

windowsforms-116666-common-features-high-dpi-support.md

latest8.4 KB
Original Source

Graphics Performance and High DPI

  • Nov 17, 2025
  • 4 minutes to read

DevExpress WinForms UI controls deliver exceptional performance and superb High DPI rendering quality. DirectX hardware acceleration improves scrolling speed, zoom efficiency, and text rendering/text antialiasing/animation quality (4K/8K).

Note

Do not use Visual Inheritance in Per-Monitor and Per-Monitor V2 modes to avoid scaling issues.

DPI Awareness Mode

A DPI Awareness Mode defines how an application renders on high resolution displays.

Unaware (Default for WinForms)Available in Windows versions before Vista. Assumes all displays use 96 DPI. On high DPI devices, Windows bitmap-scales the window, preserving layout but reducing visual clarity.SystemIntroduced in Windows Vista. Renders according to the primary display’s DPI at session start. On displays with a different resolution, Windows bitmap-scales the window, which results in blurriness.Per-Monitor / Per-Monitor V2

Adapts dynamically to each display’s DPI. Windows bitmap-scales only images and non-client areas. The application must handle WM_DPICHANGED and adjust layout.

Tip

Recommended for Windows 10+.

Enable DPI Awareness in DevExpress-powered Apps

To enable DPI awareness, open DevExpress Project Settings and select the required mode:

Call one of the following methods at startup:

csharp
using DevExpress.XtraEditors;
using System;
using System.Windows.Forms;

namespace DXApplication {
    internal static class Program {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            // Enable system DPI awareness mode.
            WindowsFormsSettings.SetDPIAware();

            // Enable Per-Monitor V2 mode for Windows 10+.
            // Otherwise, the method enables system DPI awareness mode.
            WindowsFormsSettings.SetPerMonitorDpiAware(); 

            Application.Run(new Form1());
        }
    }
}

Note

  • Do not enable DPI-awareness mode in the application manifest file.
  • First enable DPI-awareness mode, then use GDI objects (Bitmaps, Brushes, Fonts) or specify the application skin to avoid scaling issues.

Build High DPI-Ready Applications

General Recommendations

  • Restart Windows or log off/log on after changing monitor DPI settings.
  • Set the Form’s AutoScaleMode property to AutoScaleMode.Font or AutoScaleMode.DPI.
  • Define control sizes in the Visual Studio Designer, not in code.
  • Use the latest .NET version to avoid known scaling issues.
  • Run Visual Studio at 96 DPI for accurate design-time scaling.

Layout

Use flexible layouts that respond to DPI changes. Recommended containers:

Images

Use vector images (SVG icons, vector skins) or a DPIAwareImageCollection for raster images.

The following code snippet handles the WinForms Scheduler’s CustomDrawAppointment event to scale an SVG image:

csharp
void schedulerControl1_CustomDrawAppointment(object sender, CustomDrawObjectEventArgs e) {
    Point imageLocation = new Point(e.Bounds.Location.X, e.Bounds.Location.Y);
    DevExpress.Utils.Svg.SvgImage svgImage = svgImageCollection1[0];
    float factor = ScaleDPI.ScaleFactor.Width;
    e.Cache.DrawSvgImage(svgImage, imageLocation, null, factor);
    e.Handled = true;
}
vb
Private Sub schedulerControl1_CustomDrawAppointment(ByVal sender As Object, ByVal e As CustomDrawObjectEventArgs)
    Dim imageLocation As New Point(e.Bounds.Location.X, e.Bounds.Location.Y)
    Dim svgImage As DevExpress.Utils.Svg.SvgImage = svgImageCollection1(0)
    Dim factor As Single = ScaleDPI.ScaleFactor.Width
    e.Cache.DrawSvgImage(svgImage, imageLocation, Nothing, factor)
    e.Handled = True
End Sub

Custom Drawing

DevExpress WinForms UI controls expose CustomDraw~ events that allow you to paint UI elements manually. With High DPI support, use the e.Cache (GraphicsCache) event parameter instead of e.Graphics:

csharp
e.Cache.DrawString(...); // Recommended
vb
e.Cache.DrawString(...) ' Recommended

Control-Specific DPI Settings

Troubleshooting

To trace all APIs that are not recommended for use with DirectX-rendered and Per-Monitor DPI-aware applications, call the static WindowsFormsSettings.ForcePaintApiDiagnostics method and set the security level as the first parameter:

Security LevelDescription
ThrowThrows an exception when an unsupported API is used.
TraceWrites a warning in the Output window.
DisablePerforms no action. Ignores unsupported API.
DefaultActs as Trace for DirectX/Per-Monitor High DPI, otherwise behaves as Disable.
csharp
using DevExpress.XtraEditors;
using DevExpress.Utils.Diagnostics;

namespace Test {
    internal static class Program {
        [STAThread]
        static void Main() {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            WindowsFormsSettings.ForcePaintApiDiagnostics(PaintApiDiagnosticsLevel.Trace);

            Application.Run(new Form1());
        }
    }
}
vb
Imports DevExpress.XtraEditors
Imports DevExpress.Utils.Diagnostics

Namespace Test
    Friend Module Program
        <STAThread>
        Sub Main()
            Application.EnableVisualStyles()
            Application.SetCompatibleTextRenderingDefault(False)

            WindowsFormsSettings.ForcePaintApiDiagnostics(PaintApiDiagnosticsLevel.Trace)

            Application.Run(New Form1())
        End Sub
    End Module
End Namespace

Optimize Graphics Performance in Remote Environments

To improve performance:

See Also

DPI and Device-Independent PixelsAn in-depth article that explains DPI concepts.Writing DPI-Aware Desktop and Win32 ApplicationsA complete Microsoft guide on writing DPI-aware applications.