Completed
Last Updated: 28 Feb 2018 14:33 by ADMIN
ADMIN
Dimitar
Created on: 27 Nov 2017 11:52
Category: Forms/Dialogs/Templates
Type: Bug Report
0
FIX. RadShapedForm - the form is not scaled when the application is started
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);
    }
}

(Total attached files size should be smaller than 20mb. Allowed extensions: .zip, .rar, .jpg, .png, .gif)
0 comments