目标是在左键单击并拖动鼠标时平移窗体或窗体上的图像。下面的代码非常适合我的需要,但只有一个问题。当我左键单击并拖动鼠标时,表单的平移速度比鼠标快,因此很尴尬。有没有什么方法可以让我以与鼠标相同的速度制作表格?这是我的代码:
Private leftClick as Point
Private Sub Form_OnMouseDown(sender as Object, e as MouseEventArgs) Handles Form.MouseDown
leftClick = e.Position
End Sub
Private Sub Form_OnMouseMove(sender as Object, e as MouseEventArgs) Handles Form.MouseMove
'Resolves issue where mouse keeps on moving even if not
Static MyPoint As New Point
If e.Location = MyPoint Then Exit Sub
MyPoint = e.Location
'If we left click anywhere on form, pan the form
If e.Button = Windows.Forms.MouseButtons.Left Then
Dim DeltaX As Integer = (leftClick.X …
Run Code Online (Sandbox Code Playgroud)