VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Drag a Form without the cursor jumping to 0-0 on the form. Pure Math solution. No API call required

by Julius Heath (1 Submission)
Category: Custom Controls/Forms/Menus
Compatability: VB 6.0
Difficulty: Unknown Difficulty
Originally Published: Sun 7th October 2001
Date Added: Mon 8th February 2021
Rating: (1 Votes)

Drag a Form without the cursor jumping to 0-0 on the form. Pure Math solution. No API call required.

API Declarations


Dim LocatorX As Integer
Dim LocatorY As Integer
Dim XSpace As Integer
Dim YSpace As Integer

Rate Drag a Form without the cursor jumping to 0-0 on the form. Pure Math solution. No API call required



MouseEvent = 1
LocatorX = X
LocatorY = Y
XSpace = Int(X - (Y / Form1.Height))
YSpace = Int(Y - (X / Form1.Width))
End Sub


Private Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)

If MouseEvent = 1 Then
    Form1.Top = Form1.Top + Y - YSpace
    Form1.Left = Form1.Left + X - XSpace
End If
End Sub

Private Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
MouseEvent = 0
End Sub

Download this snippet    Add to My Saved Code

Drag a Form without the cursor jumping to 0-0 on the form. Pure Math solution. No API call required Comments

No comments have been posted about Drag a Form without the cursor jumping to 0-0 on the form. Pure Math solution. No API call required. Why not be the first to post a comment about Drag a Form without the cursor jumping to 0-0 on the form. Pure Math solution. No API call required.

Post your comment

Subject:
Message:
0/1000 characters