If you run the code below it will only obviously drag the first drawing item only.
Can anyone help me modify this so l can...
1) Drag each 'x' independantly
2) i need 128 drawings so the array needs to be put into a loop.
Hope there's someone out there that can put me out of my misery
Bish
Can anyone help me modify this so l can...
1) Drag each 'x' independantly
2) i need 128 drawings so the array needs to be put into a loop.
VB.NET:
Public Class Form1
Dim letterbox As Rectangle() = {New Rectangle(10, 10, 15, 15), _
New Rectangle(10, 30, 15, 15), _
New Rectangle(10, 50, 15, 15)}
Private dragOrigin As Point
Private Sub Form1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
If Me.IsDragging(e) Then
Me.dragOrigin = e.Location
End If
End Sub
Private Sub Form1_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
If Me.IsDragging(e) Then
Me.Invalidate(Me.letterbox(0))
Me.letterbox(0).Offset(e.X - Me.dragOrigin.X, e.Y - Me.dragOrigin.Y)
Me.Invalidate(Me.letterbox(0))
Me.dragOrigin = e.Location
End If
End Sub
Private Sub Form1_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles Me.Paint
For a = 0 To 2
e.Graphics.DrawString("X", Me.Font, Brushes.Black, Me.letterbox(a))
Next a
End Sub
Private Function IsDragging(ByVal e As MouseEventArgs) As Boolean
Return e.Button = Windows.Forms.MouseButtons.Left AndAlso Me.letterbox(0).Contains(e.Location)
End Function
End Class
Hope there's someone out there that can put me out of my misery
Bish