Search code examples
c#.netwinformsdesigner

How to mirror the Form without mirroring the Title Bar (RightToLeftLayout) in WinForms


I try to mirror the Form. so I enabled the both properties. RightToLeft and RightToLeftLayout. But the title bar is mirrored also.

What I try to do is override CreateParams in the following way inside CustomForm class:

public class CustomiForm : Form
{
    const int WS_EX_LAYOUTRTL = 0x400000;
    const int WS_EX_NOINHERITLAYOUT = 0x100000;
    private bool rightToLeftLayout = false;

    protected override CreateParams CreateParams
    {
        get
        {
            CreateParams CP;
            CP = base.CreateParams;
            if (this.RightToLeft == RightToLeft.Yes)
                 CP.ExStyle = CP.ExStyle | WS_EX_LAYOUTRTL | WS_EX_NOINHERITLAYOUT;
            return CP;
        }
   }
}

The result now is same the Title Bar is mirrored:

See Image


Solution

  • There's no way to do such thing in WinForms. The best thing is to use normal Form.RightToLeft and RightToLeftLayout.