3

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  


Post a Comment

  1. very nice guide for beginners .. thanks

    ReplyDelete
  2. And here I am, in 2018.

    Thank you for your help!

    ReplyDelete
  3. Respect and that i have a keen present: How Many Houses Has Hometown Renovated home renovation services

    ReplyDelete

 
Top