Feb 18, 2012
I need some code to draw a resizable, draggable rectangular cursor (or selection box) on a picturebox. I found some excellent code (albeit rather old) that does just that, but on a form rather than a picturebox. I have tried converting the code - basically moving things to the picturebox events (Paint, MouseDown, MouseMove etc). It nearly works but leaves a trail behind it when you move or resize the cursor. In other words, the selection rectangle is not being erased before being drawn in the new position.
View 1 Replies
Is there some fundamental difference between drawing graphics on a form and drawing on a picturebox that would cause this behaviour? Something like, when you invalidate a form and cause a redraw it erases what you did last? If not, then I just need to dig a bit further and work out how the cursor is being erased from the previous position.
Here's the original code that works fine on a form:
Private DragRect As New RectangleF(20, 20, 100, 80)
Private Adornments(7) As RectangleF
Private MouseInRect As Boolean = False