Completed
Last Updated: 11 Jul 2017 13:02 by ADMIN
ADMIN
Hristo
Created on: 06 Jul 2017 07:37
Category: Form
Type: Bug Report
0
FIX. RadForm - resizing is enabled even when the form has FormBorderStyle set to fixed when a StatusStrip is added to the form
How to reproduce:
Add a StatusStrip to the form and set the FormBorderStyle to FixedSingle, you will notice that the form can be resized using the sizing grip of the status strip

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

        this.FormBorderStyle = FormBorderStyle.FixedSingle;
    }

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

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

    public override bool HandleWndProc(ref Message m)
    {
        if ((m.Msg) == NativeMethods.WM_NCLBUTTONDOWN)
        {

            Point screenLocation = new Point(m.LParam.ToInt32());
            Point location = this.GetMappedWindowPoint(screenLocation);

            RadElement itemUnderMouse = this.Form.ElementTree.GetElementAtPoint(location);
            MouseEventArgs args = new MouseEventArgs(Control.MouseButtons, 1, location.X, location.Y, 0);

            bool isFixed = false;
            if (this.Form != null &&
                this.Form.FormBorderStyle == FormBorderStyle.Fixed3D ||
                this.Form.FormBorderStyle == FormBorderStyle.FixedDialog ||
                this.Form.FormBorderStyle == FormBorderStyle.FixedSingle ||
                this.Form.FormBorderStyle == FormBorderStyle.FixedToolWindow)
            {
                isFixed = true;
            }

            if (isFixed &&
                itemUnderMouse != null &&
                itemUnderMouse.Enabled &&
                !object.ReferenceEquals(itemUnderMouse, (this.Form.RootElement.Children[0] as RadFormElement).TitleBar))
            {
                return true;
            }
        }

        return base.HandleWndProc(ref m);
    }
}

0 comments