Andy
Andy

Reputation: 407

How to disable both Resize and Move for a Windows Form

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);
    }

Upvotes: 0

Views: 4663

Answers (1)

Rahul Tripathi
Rahul Tripathi

Reputation: 172378

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

Upvotes: 3

Related Questions