SftTabs/OCX 7.0 is Per-Monitor v2 DPI-aware. A tab control in a Per-Monitor v2 aware application re-renders automatically when its window moves to a monitor of a different DPI or when the system DPI changes. The control owns the metrics it controls; the application owns the images, fonts and pixel dimensions it provides. Two opt-in properties let the application hand the images and the pixel dimensions over to the control as well.
The application must declare its DPI awareness. An application built with Visual Basic 6.0 is not DPI aware unless its manifest says so. Without a declaration, Windows renders the application at 96 DPI and stretches the result on a high-DPI monitor: the DPI property returns 96, the DPI never changes and the DPIChanged event is never fired.
Per-Monitor v2 awareness is declared in the application's manifest:
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
Visual Basic positions and sizes the controls of a form itself and does not adjust a form when it moves to another monitor. An application that declares Per-Monitor v2 awareness is responsible for the layout of its forms at each DPI. The DPI property returns the tab control's current monitor DPI (96 at 100%, 120 at 125%, 144 at 150%, 192 at 200%).
In a DPI aware application, the tab control scales these metrics itself, without any application involvement:
Two independent properties decide whether images and pixel dimensions supplied by the application also scale with DPI. Both use SftTabsScalingConstants and both default to scalingSftTabsAsIs, which preserves the behavior of applications written for earlier versions.
| Property | Covers | scalingSftTabsAsIs (default) | scalingSftTabsStretch |
|---|---|---|---|
| ImageScaling | Every image the tab control draws: the tab images (including their hot and disabled variants), the background bitmaps and the custom scroll button and Close, Minimize and Restore button bitmaps. | Images are drawn at their native pixel size. Images prepared at 96 DPI look physically smaller on a high-DPI monitor. | Images are scaled by current DPI / 96 when they are drawn. |
| PixelScaling | Pixel dimensions supplied by the application: the left and right margins, the row indentation and the forced tab size of the SftTabsTabs object. | The values are used as is, in physical screen pixels. A margin of 10 is 10 pixels on any monitor. | The values are interpreted as 96-DPI reference pixels. A margin of 10 is 10 pixels at 100%, 15 pixels at 150% and 20 pixels at 200%. The property values themselves do not change. |
When the control's monitor DPI changes, the DPIChanged event is fired. The application should assign a font sized for the new DPI (the control does not own the application's font) and adjust the size and position of the tab control and the controls on its tab pages. Images, margins, row indentation and forced tab size need no further action when the two scaling properties are set to scalingSftTabsStretch.
Per-Monitor v2 DPI awareness requires Windows 10 version 1703 or later.