Make A Form That The User Can Not Move

You can set the form Moveable property to False, but if you will try to do that in runtime, you will get an error message. This code will show you how to do that properly.


Add 1 Command Button to your form

Module Code

Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, _
ByVal bRevert As Long) As Long
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, _
ByVal nPosition As Long, ByVal wFlags As Long) As Long

Public Const SC_MOVE = &HF010&
Public Const MF_BYCOMMAND = &H0&

Form Code

Private Sub Command1_Click()
    lhSysMenu = GetSystemMenu(Me.hwnd, False)
    lRetVal = RemoveMenu(lhSysMenu, SC_MOVE, MF_BYCOMMAND)
End Sub

Go Back