Di bawah ini merupakan fungsi VB6 (menggunakan fungsi API) untuk men-drag form yang tidak memiliki Control Box.
Option Explicit
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
Public Sub DragForm(frm As Form)
Dim lngReturnValue As Long
Call ReleaseCapture
lngReturnValue = SendMessage(frm.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End Sub
Contoh penggunaan drag form yang tidak memiliki controlbox
Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
DragForm Me
End Sub