改变位置可以用下面的代码:
(假设要移动的控件是Picture1)
Option ExplicitDim bgnX As Single, bgnY As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
bgnX = X
bgnY = Y
End If
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
With Picture1
.Move .Left + X - bgnX, .Top + Y - bgnY
End With
End If
End Sub要改变大小,可以尝试在需要改变大小的控件的四周添加可以响应Move事件的控件,
在Move事件中处理。当然这种方法只对可作为控件容器的控件有用,但是变通一下应该可以对也任何控件有用。
(假设要移动的控件是Picture1)
Option ExplicitDim bgnX As Single, bgnY As Single
Private Sub Picture1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
bgnX = X
bgnY = Y
End If
End SubPrivate Sub Picture1_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = vbLeftButton Then
With Picture1
.Move .Left + X - bgnX, .Top + Y - bgnY
End With
End If
End Sub要改变大小,可以尝试在需要改变大小的控件的四周添加可以响应Move事件的控件,
在Move事件中处理。当然这种方法只对可作为控件容器的控件有用,但是变通一下应该可以对也任何控件有用。
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货