0

my Windows Form FormBorderStyle is none, but I want to disable resize function like below code, How Can I implement, Thanks!

    //disable move
    protected override void WndProc(ref Message message)
    {
        const int WM_SYSCOMMAND = 0x0112;
        const int SC_MOVE = 0xF010;

        switch (message.Msg)
        {
            case WM_SYSCOMMAND:
                int command = message.WParam.ToInt32() & 0xfff0;
                if (command == SC_MOVE)
                    return;
                break;
        }

        base.WndProc(ref message);
    }
Andy
  • 407
  • 2
  • 14
  • 30

1 Answers1

3

You are looking for

form.FormBorderStyle = FormBorderStyle.FixedSingle;

This will prevent the form to resize.

However if you want to disable the move also then you need to first maximize your form and then disable the resize by setting it FixedSingle

Rahul Tripathi
  • 168,305
  • 31
  • 280
  • 331
  • Thanks! But my FormBorderStyle is `none`, could I use `FixedSingle` and `none` at the same time? – Andy Mar 18 '15 at 06:14
  • @Andy:- I dont think you can use both at the same.time. However if you want to prevent your form to be resized then you should use FixedSingle only not the none. – Rahul Tripathi Mar 18 '15 at 06:15
  • @Andy:- Also if you want to disable the move then first you maximize the form and then disable the resize. – Rahul Tripathi Mar 18 '15 at 06:16
  • I want to make the form border invisible, so I set the FormBorderStyle to `none`. Do I have other method to make border invisible and disable move and resize function? – Andy Mar 18 '15 at 06:21
  • 1
    @Andy:- In that case you can just make it to none and maximize your form next. Also set the property of maximize to true using the property tab of the form. – Rahul Tripathi Mar 18 '15 at 06:25
  • 1
    @Andy:- Check this:- http://stackoverflow.com/questions/1119256/how-do-i-prevent-a-form-from-being-resized-by-the-user – Rahul Tripathi Mar 18 '15 at 06:30