VB的又一个编程问题

来源:百度知道 编辑:UC知道 时间:2024/06/28 03:59:25
x1、y1已声明为模块级变量,鼠标按下的事件过程如下:
Private Sub Pic1_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
x1 = x : y1 = y
End Sub
编制事件过程Pic1_MouseUp,使得在图片框控件Pic1上拖动鼠标后,绘制出一个矩形。鼠标按下、抬起的位置分别为矩形斜对角线的顶点,矩形轮廓线为红色,矩形内部填充色为绿色。

类似这样子啦

Private Sub Pic1_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
x1 = x : y1 = y
End Sub
Private Sub Pic1_MouseUP(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
x2 = x : y2 = y

me.DrawRect(x1,y1,x2,y2)

End Sub

Dim x1, x2, y1, y2
Private Sub Pic1_MouseDown(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
x1 = X: y1 = Y
End Sub
Private Sub Pic1_MouseUP(Button As Integer, Shift As Integer, _
X As Single, Y As Single)
x2 = X: y2 = Y
Pic1.Cls
Pic1.FillColor = RGB(0, 255, 0)
Pic1.Line (x1, y1)-(x2, y2), RGB(255, 0, 0), B

End Sub