tags:

views:

11

answers:

0

This is the code which I am using for LineShape control drag n drop.LineShape control from powerpacks.dll

I am not able to move the Lineshape control freely. Cursor is slipping while drag n drop .

Any ideas? I have to move the lineshape control freely like lineshape control at design time with mouse cursor.

Dim fdragging As Boolean = False
Dim StartX, startY As Integer
Dim CursorPosition As Point

Private Sub LineShape1_MouseDown(ByVal sender As System.Object, _
                          ByVal e As System.Windows.Forms.MouseEventArgs) _
                          Handles LineShape1.MouseDown
    fdragging = True
    StartX = e.X
    startY = e.Y
    'CursorPosition = New Point(LineShape1.EndPoint _
                                    - LineShape1.StartPoint) _
                                    - (New Point(StartX, startY))
End Sub
Private Sub LineShape1_MouseMove(ByVal sender As System.Object, _
                            ByVal e As System.Windows.Forms.MouseEventArgs) _
                            Handles LineShape1.MouseMove
    If fdragging Then
        LineShape1.StartPoint = New Point(LineShape1.StartPoint.X + e.X _
                        - StartX, LineShape1.StartPoint.Y _
                        + e.Y _
                        - startY)
        LineShape1.EndPoint = New Point(LineShape1.EndPoint.X + e.X _
                                                - StartX, _
                                            LineShape1.EndPoint.Y _
                                                + e.Y _
                                                - startY)
       ' Me.CursorPosition = Me.PointToScreen(LineShape1.EndPoint) _
       '   - CursorPosition
    End If
End Sub
Private Sub LineShape1_MouseUp(ByVal sender As System.Object, _
                            ByVal e As System.Windows.Forms.MouseEventArgs) _
                            Handles ShapeContainer1.MouseUp
    fdragging = False
    StartX = 0
    startY = 0
End Sub