定义一系列变量处理图片拖动 '处理图片拖动 Private m_Leftx As Integer Private m_Lefty As Integer Dim m_MousePosX As Integer Dim m_MousePosY As Integer Dim m_DriftX As Integer Dim m_DriftY As Integer 并给赋初值,可以在Form初始化时做 Me.m_Leftx = Me.PictureBox1.Location.X Me.m_Lefty = Me.PictureBox1.Location.Y
定义处理鼠标按下的事件
'当鼠标按下时,将鼠标变成手形,并且记录下当前鼠标的位置 Private Sub PictureBox1_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseDown
End Sub 定义处理鼠标抬起的事件 '处理鼠标按键抬起的事件,根据鼠标按下时保存的鼠标位置,和当前鼠标的位置,计算鼠标移动偏移量,借此调用移动图片的函数,移动图片 Private Sub PictureBox1_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseUp