VB让控件可以当标题栏拖动

运用本段代码可以使任意控件像窗体标题栏一样具有拖动窗体的功能。
先在模块中加入以下代码:
Public Declare Function ReleaseCapture Lib “user32” () As Long
Public Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lparam As Any) As Long

Public Sub DoDrag(TheForm As Form)
If TheForm.WindowState vbMaximized Then
ReleaseCapture
SendMessage TheForm.hwnd, &HA1, 2, 0&

End If
End Sub
用法:
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
DoDrag Me '可以当标题栏拖动
End Sub

其中的Label1是控件名,可以替换成其他控件。