To reproduce:
- Add shaped form with some buttons to a DPI-aware application.
- Start it on an HDPI monitor.
- The form is not scaled.
Workaround:
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Screen showScreen = Screen.FromControl(this);
SizeF scale = NativeMethods.GetMonitorDpi(showScreen, NativeMethods.DpiType.Effective);
var currentDpi = (int)Math.Round(scale.Width * 96f, MidpointRounding.AwayFromZero);
if (scale.Width != 1)
{
var fi = typeof(ShapedForm).GetField("currentDpi", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
fi.SetValue(this, currentDpi);
var mi = typeof(ShapedForm).GetMethod("HandleDpiChanged", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic);
mi.Invoke(this, null);
}
}