如果你是在窗体上的 那么使用窗体的mouse_down事件判断鼠标是否在line属性 x1,y1和x2,y2之间 然后使用mouse_move修改line 的属性也就是x1,y1和x2,y2的值 Dim bifMove As Boolean Dim MousePointx As Single Dim MousePointy As SinglePrivate Sub Form_Load() bifMove = False End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) If Line1.X1 = Line1.X2 Then If Line1.X1 <> X Then Exit Sub End If If (Y > Line1.Y1 And Y < Line1.Y2) Or (Y < Line1.Y1 And Y > Line1.Y2) Then MousePointx = X MousePointy = Y bifMove = True End If Else If Line1.Y1 <> Y Then Exit Sub End If If (X > Line1.X1 And X < Line1.X2) Or (X < Line1.X1 And X > Line1.X2) Then MousePointx = X MousePointy = Y bifMove = True End If End IfEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Me.Refresh End If End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) bifMove = False End Sub还有问题请说
但问题是,我用picture1.line ()-() 画出的图是没有名字的, 所以用不了你说的方法, 我想首先要让画出的图成为一个个对象,但就是这个我不会, 有人说过 ====================================================== (首先你要为你的每个图形建立对象GC(最好为他们建立一个接口I_Graphic),其中保存有如何绘制自己的信息,另外,在加上 zorder. zorder 初始为绘画顺序。 然后,写一个函数,根据GC和鼠标位置得出最上层的图形对象。 function IsIntersect(pGo as I_Graphic,pPoint as Point) as boolean依次检查所有图形: maxzorder=0 dim selgro as I_Graphic for each gro in AllGraphics if gro.zorder>maxzorder and IsIntersect(gro,mousepoint) then maxzorder = gro.zorder set selgro = gro end if next============================= 但我不明白,具体怎样做
它们是对象,当然可以移动啦试试看
那么使用窗体的mouse_down事件判断鼠标是否在line属性 x1,y1和x2,y2之间
然后使用mouse_move修改line 的属性也就是x1,y1和x2,y2的值
Dim bifMove As Boolean
Dim MousePointx As Single
Dim MousePointy As SinglePrivate Sub Form_Load()
bifMove = False
End SubPrivate Sub Form_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Line1.X1 = Line1.X2 Then
If Line1.X1 <> X Then
Exit Sub
End If
If (Y > Line1.Y1 And Y < Line1.Y2) Or (Y < Line1.Y1 And Y > Line1.Y2) Then
MousePointx = X
MousePointy = Y
bifMove = True
End If
Else
If Line1.Y1 <> Y Then
Exit Sub
End If
If (X > Line1.X1 And X < Line1.X2) Or (X < Line1.X1 And X > Line1.X2) Then
MousePointx = X
MousePointy = Y
bifMove = True
End If
End IfEnd SubPrivate Sub Form_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If bifMove = True Then
Line1.X1 = Line1.X1 - (MousePointx - X)
Line1.Y1 = Line1.Y1 - (MousePointy - Y)
Line1.X2 = Line1.X2 - (MousePointx - X)
Line1.Y2 = Line1.Y2 - (MousePointy - Y)
MousePointx = X
MousePointy = Y
Me.Refresh
End If
End SubPrivate Sub Form_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
bifMove = False
End Sub还有问题请说
所以用不了你说的方法,
我想首先要让画出的图成为一个个对象,但就是这个我不会,
有人说过
======================================================
(首先你要为你的每个图形建立对象GC(最好为他们建立一个接口I_Graphic),其中保存有如何绘制自己的信息,另外,在加上 zorder.
zorder 初始为绘画顺序。
然后,写一个函数,根据GC和鼠标位置得出最上层的图形对象。
function IsIntersect(pGo as I_Graphic,pPoint as Point) as boolean依次检查所有图形:
maxzorder=0
dim selgro as I_Graphic
for each gro in AllGraphics
if gro.zorder>maxzorder and IsIntersect(gro,mousepoint) then
maxzorder = gro.zorder
set selgro = gro
end if
next=============================
但我不明白,具体怎样做