SftMask/OCX 8.0 is fully Per-Monitor v2 DPI-aware. A masked edit control hosted on a Per-Monitor v2 aware top-level window 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 caller owns the images, fonts and pixel dimensions it provides. Two opt-in properties let the caller hand the error images and the pixel dimensions over to the control as well.
The host application must declare Per-Monitor v2 DPI awareness. This is the single most common reason high-DPI applications do not re-render correctly when moved between monitors of different DPI. Without a Per-Monitor v2 declaration, Windows keeps the process in System-aware mode: the DPI is fixed for the process lifetime, the control does not observe DPI changes, the DPIChanged event is never fired, and high-DPI monitors render at System-DPI sizes stretched by Windows.
Declare Per-Monitor v2 awareness in the host application's manifest, for example:
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">PerMonitorV2</dpiAwareness> <dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
In a .NET project, this corresponds to selecting Per Monitor V2 for the application's DPI awareness. The DPI property returns the control's current monitor DPI (96 at 100%, 120 at 125%, 144 at 150%, 192 at 200%). If the returned value never changes as the window is dragged between monitors with different scale factors, the host is not in Per-Monitor v2 mode.
When the host is Per-Monitor v2 aware, the control picks up the new DPI on every DPI change and repaints without any caller involvement. The control's layout (the height of the edit area, the caption and the buttons) is derived from its font, so it follows the font the container supplies for the new DPI.
Two independent properties decide whether caller-supplied images and caller-supplied pixel dimensions also scale with DPI. Both use SftMaskScalingConstants and both default to scalingSftMaskAsIs, which preserves the behavior of applications written for earlier versions.
| Property | Covers | scalingSftMaskAsIs (default) | scalingSftMaskStretch |
|---|---|---|---|
| ImageScaling | The error images defined using the ImageInvalid, ImageEmpty and ImageRequired properties. | 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 | The caption width (Caption.WidthPix and Caption.Width properties). | The width is used as is, in physical screen pixels. | The width is interpreted as 96-DPI reference pixels. A width of 100 is 100 pixels at 100%, 150 pixels at 150% and 200 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 if the container does not already do so (the control does not own the application's font); with AutoSize set to True, the control adjusts its height to the new font. Error images and the caption width need no further action when the two scaling properties are set to scalingSftMaskStretch.
Per-Monitor v2 DPI awareness requires Windows 10 version 1703 or later.