标题:[求助]关于在Picture中用鼠标绘图的问题!
只看楼主
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
 问题点数:0 回复次数:4 
[求助]关于在Picture中用鼠标绘图的问题!

'定义Picture坐标系,绘制中轴线
Private Sub Command1_Click()
Dim Y%, X%
Me.Picture1.Scale (0, 100)-(200, 0)
Me.Picture1.Line (0, 50)-(200, 50), vbRed
End Sub

'按下鼠标获取点坐标
Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CurrentX = X
CurrentY = Y
End Sub
'画线
Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then
Me.Picture1.Line -(X, Y), vbBlue
End If
End Sub

问题:
如何修改才能得到不连续的任意曲线?(即鼠标按下后再按下鼠标,在两点之间不会形成连线!)

多谢指教!

搜索更多相关主题的帖子: 鼠标 Picture 绘图 
2007-07-25 23:31
zrgong
Rank: 1
等 级:新手上路
帖 子:95
专家分:0
注 册:2007-6-26
得分:0 
加个变量判断:
一开始设置:mblnIsDrawing=False

当鼠标左键点下时,设置mblnIsDrawing=True

鼠标放开时设置为:mblnIsDrawing=False

Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
if button=vbleftbutton then
mblnisdrawing=true
CurrentX = X
CurrentY = Y
endif
End Sub

Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If mblnisdrawing Then
Me.Picture1.Line -(X, Y), vbBlue
End If
End Sub

Private Sub picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
if button=vbleftbutton then
mblnisdrawing=false
endif
End Sub

2007-07-25 23:48
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
得分:0 

首先感谢楼上兄弟的热情帮助!
按照上述方法问题仍然得不到解决,调试时得到的依然是连续曲线.


当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-07-26 09:00
zhulei1978
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:53
帖 子:1351
专家分:1200
注 册:2006-12-17
得分:0 

'定义Picture坐标系,绘制中轴线
Dim nm
Private Sub Command1_Click()
Dim Y%, X%
Me.Picture1.Scale (0, 100)-(200, 0)
Me.Picture1.Line (0, 50)-(200, 50), vbRed
End Sub

Private Sub Form_Load()
nm = 1
End Sub

'按下鼠标获取点坐标
Private Sub picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
CurrentX = X
CurrentY = Y
End Sub
'画线
Private Sub picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button Then
If nm = 1 Then
Me.Picture1.Line (X, Y)-(X, Y), vbBlue
nm = 2
Else
Me.Picture1.Line -(X, Y), vbBlue
End If
End If
End Sub

Private Sub picture1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
nm = 1
End If
End Sub

[此贴子已经被作者于2007-7-26 18:32:11编辑过]


其实我就是改变社会风气,提高少女素质,刺激电影市道,提高年轻人内涵,玉树临风,风度翩翩的整蛊专家,我名叫古晶,英文名叫JingKoo!
2007-07-26 15:27
kaishiuexi
Rank: 1
等 级:新手上路
帖 子:264
专家分:0
注 册:2007-6-8
得分:0 

感谢^_^


当白天又一次把黑夜按翻在床上的时候,太阳就出生了……
2007-07-27 13:47



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-158139-1-1.html




关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.042712 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved