Not allowing user to move a form


I have some MDI app and i dont want the users to be able to move the windows.  How i can stop the user being able to move the form by clicking on the title bar?

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Place this in the form code:

    Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
        Const WM_NCHITTEST As Integer = &H84
        Const HTCLIENT As Integer = &H1
        Const HTCAPTION As Integer = &H2

        Select Case m.Msg
            Case WM_NCHITTEST
                If (m.Result.ToInt32 = HTCAPTION) Then
                    m.Result = IntPtr.op_Explicit(HTCLIENT)
                End If
                Exit Sub
        End Select

    End Sub

cehck this

another method will be ...

Protected Overrides Sub WndProc(ByRef m As Message)
 const Integer WM_NCLBUTTONDOWN = 161
 const Integer WM_SYSCOMMAND = 274
 const Integer HTCAPTION = 2
 const Integer SC_MOVE = 61456
If (m.Msg = WM_SYSCOMMAND) &&(m.WParam.ToInt32() = SC_MOVE) Then
End If
If (m.Msg = WM_NCLBUTTONDOWN) &&(m.WParam.ToInt32() = HTCAPTION) Then
End If

MyBase.WndProc( m)
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
I like that one better, just ignores the request as apposed to the example I gave which tricks it into thinking you are clicking the form area.

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.