by Aaron Duke (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 2nd March 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
To move a form without borders or to move any other object with a mouse when the user clicks on it and releases.
API Declarations
Public oldX As Integer
Public oldY As Integer
Private Sub mover_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
msDown = True 'Tells it the mouse is down on the object
oldX = X 'Gets the X position of the mouse on the object
oldY = Y 'Gets the Y position of the mouse on the object
End Sub
Private Sub mover_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If msDown = True Then 'If the mouse is down then...
Form1.Left = Form1.Left + X - oldX 'Move the form with the mouse
Form1.Top = Form1.Top + Y - oldY
End If
End Sub
Private Sub mover_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
msDown = False 'Tells it the mouse has been released
End Sub
No comments have been posted about To move a form without borders or to move any other object with a mouse when the user clicks on it . Why not be the first to post a comment about To move a form without borders or to move any other object with a mouse when the user clicks on it .