HeaderPane
Main
Hide
Share Link
Print

Per-Monitor DPI and Scaling

SftDate/NET 3.0 supports per-monitor DPI awareness (Per-Monitor v2). In a per-monitor aware application, the controls adapt when their window moves to a monitor with a different scale factor: the field, its buttons, the dropdown, the calendar and the clock face are sized for the monitor's DPI, and the calendar's fonts are scaled like the control's own font. A dropdown opened on another monitor than its field uses the DPI of that monitor.

A Windows Forms application becomes per-monitor aware with this setting in its app.config file (.NET Framework 4.7 or later), together with Windows 10 compatibility in its application manifest:

<System.Windows.Forms.ApplicationConfigurationSection>
  <add key="DpiAwareness" value="PerMonitorV2" />
</System.Windows.Forms.ApplicationConfigurationSection>

A .NET 10 application becomes per-monitor aware by calling Application.SetHighDpiMode(HighDpiMode.PerMonitorV2) before it creates its first window.

The control's DeviceDpi property returns the DPI of the monitor showing the control, and the DpiChangedAfterParent event occurs when it changes. Both are inherited from the Control class. The SftDate/NET samples are per-monitor aware.

The ImageScaling property defines how the images of special dates and of the DayFormatting event follow the DPI. With ImageScalingEnum.AsIs (the default), images are drawn at their size in pixels; with ImageScalingEnum.Stretch, they are treated as designed for 96 DPI and are scaled with the display DPI.

Applications that are only DPI aware for the primary monitor (System DPI aware) get the same scaling at the system DPI.