# Re: 为何不能画一条直线?

Posted by Honey on November 05, 1998 at 23:14:58:

In Reply to: 为何不能画一条直线? posted by chris on October 31, 1998 at 12:18:23:

: 请问为何在PictureBox画不出一条直线,而是不断的画直线?

: Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
: If Button = 1 Then
: sngoldX = X
: sngoldY = Y
: End If
: End Sub

: Private Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
: If Button = 1 Then
: Picture1.Line (sngoldX, sngoldY)-(CurrentX, CurrentY), RGB(255, 255, 255)
: Picture1.Line (sngoldX, sngoldY)-(X, Y), RGB(0, 0, 0)
: End If
: End Sub
: 那有问题?

简单描述一下你的程式
当_MouseDown事件发生时 纪录下了座标
当_MouseMove事件发生时 便由原纪录的
座标画线到现在的座标 于是便是不断画线......

如果要在 "滑鼠放开时" 画一条线
要在_MouseUp事件发生时的滑鼠座标和
纪录的座标连线 OK

Follow Ups: