Drive of Forms c#

Asked

Viewed 1,523 times

1

I have a menu and some children Forms...and I want them not to be able to click the form and drag, as I do ? I want him to stand still in the position and size I put.

  • 1

    Welcome to Stack Overflow! Do you have any examples of the code you’ve tried? You could post it along with your question?

1 answer

1

Well I didn’t understand much but from what I understand you don’t want the user to be able to resize the form check this option in the properties

inserir a descrição da imagem aqui This locks the form and does not allow resizing, otherwise disable the Maximizebox property, set it to false to lock the form maximize button

then to block the movement take this code and paste it into the form code

 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);
        }
  • if I click on the safe form the left mouse button and drag it moves, got it? I don’t want it to mexxa

  • a understood you do not want beyond that the user does not move the form by the screen

  • Sam Philip. You can help me ?

  • Tai in the answer she edited the code I put in it picks it glue her in the form class

  • so in every form that I want to be immobile I must enter all this code ?!

  • Yes you put this code in the form class that you want to be immobile of a Ctrl+c in it and go Ctrl+v in the forms that you do not want to move

  • That’s cool , I’ll try

  • thanks my dear, it worked ! thank you very much !!!

  • Oops for nothing !!

Show 4 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.