|
以下代码可以创建可移动控件,使控件在运行的程序介面中能随意更改位置,用鼠标点着控件拖动即可。
Dim a!, x1!, y1!
Private Sub Command1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single) x1 = X y1 = Y a = 1 End Sub
Private Sub Command1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single) If a = 1 Then Me.Command1.Left = X - x1 + Command1.Left Me.Command1.Top = Y - y1 + Me.Command1.Top End If End Sub
Private Sub Command1_MouseUp(Button As Integer, Shift As Integer, X As Single, Y As Single) a = 0 End Sub
[]
|