想实现这样一个功能:按下鼠标定圆心,拖动时显示圆(这个过程中半径是不断变化的,圆在变大或缩小),松开鼠标,一个圆被确定
再按下鼠标,确定第二个圆的圆心,拖动鼠标时显示圆,松开鼠标,第二个圆被确定
,
再如此操作,画第三个圆
要求在视觉上,这三个圆是在同一个区域内被一个一个画上的。
大家帮我想想办法,多谢了
再按下鼠标,确定第二个圆的圆心,拖动鼠标时显示圆,松开鼠标,第二个圆被确定
,
再如此操作,画第三个圆
要求在视觉上,这三个圆是在同一个区域内被一个一个画上的。
大家帮我想想办法,多谢了
解决方案 »
- Is it possible to hide plotting data point marker on mschart ??
- 求修改密码的代码
- 紧急求救:各位大虾,怎样在vb中把系统的beep声音给屏蔽掉?
- 如何实现货币类型数据的相加?
- 请教各位侠:VB和SQL的问题
- 为什么用mscomm和单片机通讯时收到乱码?如何改进?(另外还有两大难题,高手请指点)
- SQL语句中的distinct问题,如何在一个语句中实现既对一个字段消重复又查出其它字段,在线等待!!
- 双击treeview节点选择图片
- 如何在VB中查询数据库时,让附合条件的内容象BBS里这样从上到下依次显示出来??
- 关于窗体重画的问题.
- 如何让文本框内的内容显示不同颜色(高分赠送)
- 自己写的vb-xml的例子,需要的跟贴(高手免进!)
和你要的橡皮筋效果的画圆程序相似,你把画线改成画圆吧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
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调试通过,程序较简单,不注释了。老蔡出品,绝无伪劣。
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调试通过,绝无质量问题。