Click to See Complete Forum and Search --> : Drawing square by mouse


November 18th, 1999, 02:21 PM
Hi to everyone who cared about my message.

I want to know how to delete lines in my drawing program.

Since I try to draw line, I do like this:
1. As mouse down, it is the start x and y point.
2. As mouse move, draw a line to the point that the mouse is located.

Here is a problem, As long as mouse is moving or until mouse-up, lines I have created should go away. The program just leaves the lines there. It should be just like MS paint.
If you understood my english, and know a good idea for this.
Please help me.

Aaron Young
November 18th, 1999, 11:32 PM
Try using the Invert Pen to create a RubberBand Effect, eg.

private oX as Integer
private oY as Integer
private lX as Integer
private lY as Integer

private Sub Form_Load()
Picture1.ScaleMode = vbPixels
End Sub

private Sub Picture1_MouseDown(Button as Integer, Shift as Integer, X as Single, Y as Single)
If Button = vbLeftButton then
oX = X
oY = Y
Picture1.DrawMode = vbInvert
End If
End Sub

private Sub Picture1_MouseMove(Button as Integer, Shift as Integer, X as Single, Y as Single)
If Button = vbLeftButton then
Picture1.Line (oX, oY)-step(lX - oX, lY - oY), , B
Picture1.Line (oX, oY)-step(X - oX, Y - oY), , B
End If
lX = X
lY = Y
End Sub

private Sub Picture1_MouseUp(Button as Integer, Shift as Integer, X as Single, Y as Single)
Picture1.Line (oX, oY)-step(lX - oX, lY - oY), , B
Picture1.DrawMode = vbCopyPen
Picture1.Line (oX, oY)-step(X - oX, Y - oY), , B
End Sub





Aaron Young
Analyst Programmer
adyoung@win.bright.net
aarony@redwingsoftware.com

November 19th, 1999, 09:30 AM
Thanks to Aaron. I ll try that way.