展开全部
‘注意放在窗体的MouseMove事件中,有问题HI我
Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
'按住鼠标左右键均可拖动窗体
If e.Button = MouseButtons.Left Or e.Button = MouseButtons.Right Then
Dim mousePos As Point = sender.findform().MousePosition
'获得鼠标偏移量
mousePos.Offset(-mouse_offset.X, -mouse_offset.Y)
'设置窗体随鼠标一起移动
sender.findform().Location = mousePos
End If
End Sub
Private Sub PictureBox1_MouseMove(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles PictureBox1.MouseMove
'按住鼠标左右键均可拖动窗体
If e.Button = MouseButtons.Left Or e.Button = MouseButtons.Right Then
Dim mousePos As Point = sender.findform().MousePosition
'获得鼠标偏移量
mousePos.Offset(-mouse_offset.X, -mouse_offset.Y)
'设置窗体随鼠标一起移动
sender.findform().Location = mousePos
End If
End Sub
追问
有问题
追答
不好意思
'放在窗体MouseDown
mouse_offset = New Point(e.X, e.Y)
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询