HeaderPane
Main
Hide
Share Link
Print

Per-Monitor DPI and Scaling

SftTabs/NET 3.0 supports per-monitor DPI awareness (Per-Monitor v2). In a per-monitor aware application, the tab control adapts when its window moves to a monitor with a different scale factor: tabs, buttons, tooltips and other elements the control draws itself are sized for the monitor's DPI, and fonts defined for individual parts are scaled like the control's own font. The tab pages and the controls they host are scaled by Windows Forms, like the controls of any other container.

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 SftTabs/NET samples are per-monitor aware.

Two properties define how images and pixel values defined by the application follow the DPI. Both default to AsIs:

PropertyStretch
ImageScalingAll images are treated as designed for 96 DPI and are scaled with the display DPI: images in tabs, application-defined button images, and built-in images such as close buttons, scroll buttons, check boxes and radio buttons.
PixelScalingPixel values are treated as values for 96 DPI and are scaled with the display DPI: the tab padding (SftTabs.TabPadding), the margins (SftTabs.MarginNear, SftTabs.MarginFar), the row indentation (SftTabs.RowIndent), the button gaps (ButtonsClass.Gap, ButtonsClass.ScrollButtonsGap, ScrollingClass.Gap) and the sizes of image, gap and progress bar parts.

With PixelScaling set to Stretch, properties return the values as they were set, so a form designed at one DPI looks the same at any DPI. The SftTabs.GetTabBounds, SftTabs.HitTest and SftTabs.TabFromPoint methods and the SftTabs.StripBounds and SftTabs.DisplayRectangle properties always use pixels on the display.

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