VB中动态生成的image控件如何拖动
1个回答
展开全部
Option Explicit
Dim WithEvents img As Image
Private Sub Form_Load()
Set img = Controls.Add("vb.image", "img")
img.Picture = Me.Icon
img.Stretch = True
img.MousePointer = vbSizeAll
img.ToolTipText = "按住鼠标左键可以拖动我"
img.Visible = True
End Sub
Private Sub img_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static mx%, my%
If Button = 1 Then
img.Move img.Left - mx + X, img.Top - my + Y
ElseIf Button = 0 Then
mx = X
my = Y
End If
End Sub
Dim WithEvents img As Image
Private Sub Form_Load()
Set img = Controls.Add("vb.image", "img")
img.Picture = Me.Icon
img.Stretch = True
img.MousePointer = vbSizeAll
img.ToolTipText = "按住鼠标左键可以拖动我"
img.Visible = True
End Sub
Private Sub img_MouseMove(Button As Integer, Shift As Integer, X As Single, Y As Single)
Static mx%, my%
If Button = 1 Then
img.Move img.Left - mx + X, img.Top - my + Y
ElseIf Button = 0 Then
mx = X
my = Y
End If
End Sub
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询