我有一些代码可以移动控件,但是当您到达屏幕末尾时,您必须释放鼠标右键,再次右键单击图像,然后再次拖动,.. 重复..
现在我尝试重写代码,以便在不移动鼠标的情况下移动控件。这就是我现在所拥有的:
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
Dim xx As String = DirectCast(e, MouseEventArgs).Button.ToString
If xx = "Right" Then
Dim Px As Point = New Point(Me.Location.X + SplitContainer1.Location.X + SplitContainer1.SplitterDistance + CInt((SplitContainer1.Width - SplitContainer1.SplitterDistance) / 2), Me.Location.Y + SplitContainer1.Location.Y + CInt(SplitContainer1.Height / 2))
Windows.Forms.Cursor.Position = Px
PictureBox1.Left = PictureBox1.Left + (e.X - Px.X)
PictureBox1.Top = PictureBox1.Top + (e.Y - Px.Y)
End If
End Sub
然而图像并没有移动,它随着鼠标返回到原来的位置。
如何让这段代码在不让鼠标改变位置的情况下移动图片框?