Wednesday, November 7

How to Lock a Form or How to set a form as Not Movable as well as Fixed Size


                  Here I have explained how to Lock windows form in windows application.


                 In my previous article I have explained Generate Barcode in windows application .Here I will explain how a form can’t be movable. We can lock a windows form to set as fixed position where a user can not able to resize that form as well as they can’t able to change the position of that form.

Sometimes it will be a mandatory when you want to open window inside a master form with fixed size. Then we definitely go for this approach.

It is very simple to fix a window form by some few lines of code in your windows application. For this write a override method for WndProc.

For fix the Size of your Form, Set the Properties of your Form as 


If you want to Lock your window form then write following code in your application.

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)




            base.WndProc(ref message);


Hope you will like this article, For more details similar article here.

Keep coding…


    Shibashish Mohanty


No comments:

Post a Comment

Please don't spam, spam comments is not allowed here.

shibashish mohanty