Äåêëàðèðóåì API ôóíêöèþ:
Private Declare Function SendMessage Lib "USER32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long,ByVal wParam As Long, ByVal lParam As Long) As Long
Private Declare Function ReleaseCapture Lib "USER32" () As Long
Private Const WM_NCLBUTTONDOWN = &HA1
Private Const HTCAPTION = 2
Îáðàùåíèå ê ôóíêöèè:
Public Sub DragForm(frm As Form)
On Local Error Resume Next
Call ReleaseCapture
Call SendMessage(frm.hwnd, WM_NCLBUTTONDOWN, HTCAPTION, 0)
End Sub
Äîáàâëÿåì â ñîáûòèå MouseDown ýëåìåíòà çà êîòîðûé ìû õîòèì ïåðåòàñêèâàòü ôîðìó :
If Button = acLeftButton Then
Call DragForm(Me)
End If
Ïðèìåð:
Private Sub ÎáëàñòüÄàííûõ_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = acLeftButton Then
Call DragForm(Me)
End If
End Sub