想实现这样一个功能:按下鼠标定圆心,拖动时显示圆(这个过程中半径是不断变化的,圆在变大或缩小),松开鼠标,一个圆被确定  
 
再按下鼠标,确定第二个圆的圆心,拖动鼠标时显示圆,松开鼠标,第二个圆被确定  
,  
 
再如此操作,画第三个圆  
 
要求在视觉上,这三个圆是在同一个区域内被一个一个画上的。  
 
大家帮我想想办法,多谢了  

解决方案 »

  1.   

    这是一个有橡皮筋效果的画线的程序
    和你要的橡皮筋效果的画圆程序相似,你把画线改成画圆吧Option Explicit
    Dim startx, starty, endx, endy As Integer
    '有橡皮筋效果的程序
    Private Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    Form1.AutoRedraw = False
    startx = X        '记住起始点
    starty = Y
    End SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    Form1.Refresh
    Form1.Line (startx, starty)-(X, Y)      '显示橡皮筋效果
    End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    endx = X    '记住终止点
    endy = Y
    Form1.AutoRedraw = True
    Form1.Line (startx, starty)-(endx, endy)    '最终画线
    End Sub
      

  2.   

    写给你吧:(假设画在窗体上面)Option Explicit
    Dim Xo As Long  '原点坐标
    Dim Yo As Long
    Dim R As Long     '半径
    Dim Color As Long '颜色Sub form_load()
    Color = vbRed '这个颜色可以你自己选的
    End SubSub form_mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    Xo = X
    Yo = Y
    End SubSub form_mousemove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim Dx As Long
    Dim Dy As Long
    If Button <> 1 Then Exit Sub
    Dx = X - Xo
    Dy = Y - Yo
    R = Sqr(Dx * Dx + Dy * Dy)
    Me.Refresh
    Circle (Xo, Yo), R, Color
    End SubSub form_mouseup(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    With Me
       .AutoRedraw = True
       Circle (Xo, Yo), R, Color
       .Refresh
       .AutoRedraw = False
    End With
    End Sub调试通过,程序较简单,不注释了。老蔡出品,绝无伪劣。
      

  3.   

    差点忘了,你是要在PICTUREBOX上画的,改一下:
    Option Explicit
    Dim Xo As Long
    Dim Yo As Long
    Dim R As Long
    Dim Color As LongSub form_load()
    Color = vbRed
    End SubSub picture1_mousedown(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    Xo = X
    Yo = Y
    End SubSub picture1_mousemove(Button As Integer, Shift As Integer, X As Single, Y As Single)
    Dim Dx As Long
    Dim Dy As Long
    If Button <> 1 Then Exit Sub
    Dx = X - Xo
    Dy = Y - Yo
    R = Sqr(Dx * Dx + Dy * Dy)
    Picture1.Refresh
    Picture1.Circle (Xo, Yo), R, Color
    End SubSub picture1_mouseup(Button As Integer, Shift As Integer, X As Single, Y As Single)
    If Button <> 1 Then Exit Sub
    With Picture1
       .AutoRedraw = True
       Picture1.Circle (Xo, Yo), R, Color '这个前面的可不能省哦,否则就错了哦
       .Refresh
       .AutoRedraw = False
    End With
    End Sub调试通过,绝无质量问题。