动态生成Command控件后,我要想动态移动其中任意Command控件,能否实现,在线等~~~~
动态生成Command控件后,我要想动态移动其中任意Command控件,我现在只能移动一个控件,要是想移动多个控件的话也可以,就是重复定义多个想同控件,有没有其它办法,一次性实现啊:
Option Explicit
Dim IsMove As Boolean
Dim Mx As Single, My As Single
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsMove = True
Mx = X
My = Y
End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Command1
If IsMove = True Then
.Left = .Left - Mx + X
.Top = .Top - My + Y
End If
End With
End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsMove = False
End Sub
Private Sub Command2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsMove = True
Mx = X
My = Y
End Sub
Private Sub Command2_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
With Command2
If IsMove = True Then
.Left = .Left - Mx + X
.Top = .Top - My + Y
End If
End With
End Sub
Private Sub Command2_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single)
IsMove = False
End Sub
......
这样呢,我就可以预先定义command(1~~~n)个,也可实现,但是太多了,有没有办法只用写一次就实现的,请教了....
[解决办法]
控件数组不会用?看书吧
for i = 1 to n
load command1(i)
command1(i).visiabled = true
next