The following codes allows you to drag or move a border-less Form or Control in Visual Basic 6. This also works on other controls like Label, Image or Picture Box. You can also move or drag a control inside a form.
Copy and Paste the code below in a Standard Module.
Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As Any) As Long
Declare Sub ReleaseCapture Lib "user32" ()
Public Const WM_NCLBUTTONDOWN = &HA1
Public Const HTCAPTION = 2
Then Copy and Paste the code below on a Form or Controls MouseDown Event.
Private Sub Form_MouseDown(Button As Integer, Shift As Integer, x As Single, y As Single)
Dim ReturnValue As Long
If Button = 1 Then
Call ReleaseCapture
ReturnValue = SendMessage(Me.hWnd, WM_NCLBUTTONDOWN, HTCAPTION, 0&)
End If
End Sub
very nice guide for beginners .. thanks
ReplyDeleteAnd here I am, in 2018.
ReplyDeleteThank you for your help!
Respect and that i have a keen present: How Many Houses Has Hometown Renovated home renovation services
ReplyDelete