试试这个:
更新:
更好的解决方案是:
Public Class Form1
' Just to set and store custom locations
Dim Corners As New Dictionary(Of String, Point)
' Flag to make/unmake form moveable
Private bMoveable As Boolean = True
Private Declare Function EnableMenuItem Lib "user32.dll" Alias "EnableMenuItem" (ByVal hMenu As IntPtr, ByVal uIDEnableItem As Int32, ByVal uEnable As Int32) As Int32
Public Overridable Property Moveable() As Boolean
Get
Return bMoveable
End Get
Set(ByVal Value As Boolean)
If bMoveable <> Value Then
bMoveable = Value
End If
End Set
End Property
Protected Overrides Sub WndProc(ByRef m As Message)
If m.Msg = &H117& Then
'Handles popup of system menu.
If m.LParam.ToInt32 \ 65536 <> 0 Then 'divide by 65536 to get hiword.
Dim AbleFlags As Int32 = &H0&
If Not Moveable Then AbleFlags = &H2& Or &H1&
EnableMenuItem(m.WParam, &HF010&, &H0& Or AbleFlags)
End If
End If
If Not Moveable Then
'Cancels any attempt to drag the window by it's caption.
If m.Msg = &HA1 Then If m.WParam.ToInt32 = &H2 Then Return
'Redundant but cancels any clicks on the Move system menu item.
If m.Msg = &H112 Then If (m.WParam.ToInt32 And &HFFF0) = &HF010& Then Return
End If
'Return control to base message handler.
MyBase.WndProc(m)
End Sub
Private Sub Form1_Shown(sender As System.Object, e As System.EventArgs) Handles MyBase.Shown
' Add a custom location to the dictionary
Corners.Add("BottomRight", _
New Point(Screen.PrimaryScreen.WorkingArea.Width - Me.Width, _
Screen.PrimaryScreen.WorkingArea.Height - Me.Height))
' Move the form
Me.Location = Corners("BottomRight")
' Make it unmoveable from there!
Me.Moveable = False
End Sub
End Class