Completed
Last Updated: 11 Jul 2017 13:03 by ADMIN
ADMIN
Hristo
Created on: 05 Jul 2017 10:52
Category: Form
Type: Bug Report
0
FIX. RadForm - the FormBorderStyle property is not respected when AllowTheming = false
How to reproduce:
public partial class RadForm1 : RadForm
{
    public RadForm1()
    {
        InitializeComponent();

        this.AllowTheming = false;

        this.FormBorderStyle = FormBorderStyle.FixedSingle;
    }
}

Workaround: 
public partial class RadForm1 : RadForm
{
    public RadForm1()
    {
        InitializeComponent();

        this.AllowTheming = false;

        this.FormBorderStyle = FormBorderStyle.FixedSingle;
    }

    protected override FormControlBehavior InitializeFormBehavior()
    {
        return new MyRadFormBehavior(this, true);
    }
}

public class MyRadFormBehavior : RadFormBehavior
{
    public MyRadFormBehavior(IComponentTreeHandler treeHandler, bool shouldCreateChildren)
        : base(treeHandler, shouldCreateChildren)
    { }

    public override bool HandleWndProc(ref System.Windows.Forms.Message m)
    {
        BindingFlags bindingFlags = BindingFlags.Instance | BindingFlags.NonPublic;
        if (m.Msg == NativeMethods.WM_NCHITTEST)
        {
            typeof(RadFormBehavior).GetMethod("OnWMNCHittest", bindingFlags).Invoke(this, new object[] { m });
            return true;
        }

        if (!this.AllowTheming)
        {
            return false;
        }

        return base.HandleWndProc(ref m);
    }
}
0 comments