can anyone show me small lines of code that the users are unable to move to form?
i already search on google and i found some code.. but it compose of many-many lines of code and i cant understand... i want a small lines of code... heheh
That's not really practical if you don't want the form to have no border.
There is no simple way to do this. There is no property that determines whether a form can be moved or not. It takes a bit of code. I'm not sure what you already have but if you follow the CodeBank link in my signature you'll find some code to do this.
If islocked Then Me.Location = originalpoint Else originalpoint = Me.Location
That will get the job done, so kudos for that, but it's a bit of a hack. It doesn't actually stop the form being moved but, rather, it moves the form back to its original location after it moves. As a result you can get an ugly visual effect when dragging the form. Run that code and then try dragging the form around the screen and you'll see that it appears in other locations momentarily, which looks a little unprofessional. It's not really worth allowing an application to look unprofessional to save 20 or 30 lines of code that someone else has already provided for you.
Put this in the form you want to prevent from moving:
vb.net Code:
Protected Overloads Overrides Sub WndProc(ByRef m As Message)
If (m.Msg = 274) AndAlso (m.WParam.ToInt32() = 61456) Then
Return
ElseIf (m.Msg = 161) AndAlso (m.WParam.ToInt32() = 2) Then
Return
End If
MyBase.WndProc(m)
End Sub
The only way to improve this is if there was something that also disabled the "Move" option in the ContextMenu that appears when right-clicking the top-left icon.
PC #1: Athlon64 X2+Vista64+VS2008EE+.NET3.5 #2: XP (all flavours Ghost'd)+VS2008EE+.NET3.5
Help Files: HelpMaker · Dr. Explain · Create Icons: IcoFX
"Whoever eats my flesh and drinks my blood has eternal life, and I will raise him on the last day." John 6:54
The only way to improve this is if there was something that also disabled the "Move" option in the ContextMenu that appears when right-clicking the top-left icon.
Which is what the SystemMenuManager in my aforementioned CodeBank thread does.