# Re: 如何按住 Text Box or Label 移动表单

Posted by Honey on November 06, 1998 at 23:37:52:

In Reply to: 如何按住 Text Box or Label 移动表单 posted by 请教者 on November 06, 1998 at 10:12:48:

我是用以下的方式
API宣告 若在模组宣告得去掉Private

Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Private Declare Sub ReleaseCapture Lib "user32" ()
Const WM_NCLBUTTONDOWN = &HA1
Const HTCAPTION = 2

之后在Label1 or text1 的MouseMove事件输入以下

Dim Lngk As Long
If Button = 1 Then
ReleaseCapture
LngK = SendMessage(Me.hwnd,WM_NCLBUTTONDOWN,HTCAPTION, 0&)
End If

Follow Ups: