我看下
Private Sub Image1_MouseMove(Index As Integer, Button As Integer, Shift As Integer, X As Single, Y As Single)
II = Index
Dim a
If Button = vbLeftButton Then
Image1(II).Move Image1(II).Left + X - tx - 400, Image1(II).Top + Y - ty - 200
a = Image1(0).Left
b = Image1(0).Top
C = Image1(0).Width
d = Image1(0).Height
e = Image1(1).Left
f = Image1(1).Top
g = Image1(1).Width
h = Image1(1).Height
i = (a <= e + g) And (a + C >= e)
j = (e < a + C) And (e + g > a)
k = (b <= f + h) And (b + d >= f)
l = (f <= b + d) And (f + h >= b)
If (i Or j) And (k Or l) Then
MsgBox "不能发生重叠!"
Image1(0).Left = Rnd * 5000
Image1(0).Top = Rnd * 5000
Image1(1).Left = Rnd * 5000
Image1(1).Top = Rnd * 5000
End If
End If
End Sub
不知道你要做什么!~
你可以写个for循环判断当前是否有image存在于这个位置!~
这样可以嘛?
只要保证这四个点不在其他控件的范围内就可以了