Reputation: 1960
Actually I'm creating a simple paint application in VB.Net 2010. I want to draw shapes in my application same as we do in Microsoft Paint using mouse.
I'm a bit successful also using mousedown and mouseup events of a picture box. The mousedown event sets the starting point and mouseup event sets the ending point(diagonally opposite point of rectangle.) The problem is "Nothing seems to be occuring between mousedown and mouseup events(Well..that is obvious because I didn't add any code on mousemove event). My question is: "Can I do something to see a growing rectangle during mousemove event?". The rest of the drawing should remain unaffected. Thanks!! :)
Upvotes: 0
Views: 1544
Reputation: 33738
You need to cache the image before you begin rectangle drawing (first thing you do in mousedown). then in mousemove you use that start point and the mouse location to construct a rectangle and draw it to a new bitmap (draw the cached image first, then layer the rect on top), then show the new bitmap in your pic box. finally in mouseup you set a flag that indicates that mousemove should not be doing anything (until mousedown again).
Upvotes: 1