CodeItBetter Programming Another VB Programming Blog

How to restrict the user not to move the Form

Posted on January 5, 2009
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
'Forms - How to restrict the user not to move the Form

Option Explicit
 
'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.

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&
 
'Add a Command Button to your form
Private Sub Command1_Click()
    lhSysMenu = GetSystemMenu(Me.hwnd, False)
    lRetVal = RemoveMenu(lhSysMenu, SC_MOVE, MF_BYCOMMAND)
End Sub
Filed under: Forms Leave a comment
Comments (0) Trackbacks (0)

No comments yet.


Leave a comment


 

No trackbacks yet.