各位高手,请指教橡皮擦功能怎么实现
我用Shape控件在 PictureBox中实现了画圆,画矩形,画直线的功能
我现在用的是Picture1.Cls语句,一点就全部清除了,嘿嘿~~~
谢谢指教哦 

解决方案 »

  1.   

    Option ExplicitDim BRUSH As BooleanPrivate Sub Command1_Click()
    BRUSH = True
    End SubPrivate Sub Form_Load()
    BRUSH = False
    Form1.AutoRedraw = True
    End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button = 1 And BRUSH = False Then
    Picture1.DrawWidth = 3
    Picture1.PSet (X, Y), vbRed
    End If
    If Button = 1 And BRUSH = True Then
    Picture1.DrawWidth = 10
    Picture1.PSet (X, Y), Picture1.BackColor
    End IfEnd Sub
      

  2.   

    其实说穿了,所谓的"橡皮擦",无非就是用picture控件的底色在鼠标所在位置画一个方块或圆而已,就象楼上的代码那样
      

  3.   

    Option Explicit
    Dim flag As Boolean
    Dim x1 As Integer   '起点X坐标
    Dim y1 As Integer   '起点Y坐标
    Dim x2 As Integer   '终点点X坐标
    Dim y2 As Integer   '终点Y坐标
    Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    flag = True
        x1 = X
        y1 = Y
    End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If flag = False Then
            Exit Sub
        End If
        If flag = True Then
            Picture1.DrawWidth = 16 '橡皮擦大小
            x2 = X
            y2 = Y
            Picture1.Line (x1, Y)-(x2, y2), Picture1.BackColor
            x1 = x2
            y1 = y2
        End If
    End SubPrivate Sub Picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    flag = False
    End Sub