How to move form without form border (visual studio)

后端 未结 9 2052
无人共我
无人共我 2020-12-09 13:38

I am making a windows form application in visual studio 2013 Express. In order to make the application look more customized and attractive, I designed the forms in my applic

9条回答
  •  南方客
    南方客 (楼主)
    2020-12-09 14:07

    Dim InitialMouseDownLocation As Point
    
    Private Sub PictureBox1_MouseDown(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseDown
        If e.Button = MouseButtons.Left Then
            InitialMouseDownLocation = e.Location
            Cursor.Current = Cursors.NoMove2D
        End If
    End Sub
    
    Private Sub PictureBox1_MouseMove(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseMove
        If e.Button = MouseButtons.Left Then
            Location = New Point(Location.X - InitialMouseDownLocation.X + e.X, Location.Y - InitialMouseDownLocation.Y + e.Y)
        End If
    End Sub
    
    Private Sub PictureBox1_MouseUp(sender As Object, e As MouseEventArgs) Handles PictureBox1.MouseUp
        Cursor.Current = Cursors.Default
    End Sub
    

提交回复
热议问题