با سلام
من برای حرکت دادن یک PictureBox از قطعه کد زیر که در رویداد MouseMove آن قرار میدهم استفاده میکنم
Private oControlOffsetPoint As Point
Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
Dim sX As Integer = RectangleToClient(New Rectangle(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, 1, 1)).Left - oControlOffsetPoint.X
Dim sY As Integer = RectangleToClient(New Rectangle(Windows.Forms.Cursor.Position.X, Windows.Forms.Cursor.Position.Y, 1, 1)).Top - oControlOffsetPoint.Y
If e.Button = Windows.Forms.MouseButtons.Left Then
sender.Location = New Point(sX, sY)
PictureBox1.Left = sX
PictureBox1.Top = sY
EndIf
End Sub
دو مشکل دارم
1- جایگاه نشانگر موس در هنگام حرکت رضایت بخش نیست (اگر مانند حرکت picturebox خود دات نت باشد عالی است)
2- اینکه اگر بخواهم در محدوده خاص یک PictureBox دیگر آنرا حرکت دهم چه باید بکنم
راستی PictureBox1.Capture = False چه کار میکند؟