vb.net窗体拖动,展开

如何实现窗体拖动呢,在form1.formborderstyle=none时拖动窗体

上一次的计时器,更本就拖动不了

 vb.net窗体拖动,展开_第1张图片

 主要代码如下

Public Class Form2
    Dim MovBoll As Boolean
    Dim CurrX As Integer
    Dim CurrY As Integer
    Dim MousX As Integer
    Dim MousY As Integer

  Private Sub Form2_MouseDown(sender As Object, e As MouseEventArgs) Handles Me.MouseDown
        MousX = e.X
        MousY = e.Y
        MovBoll = True
    End Sub

    Private Sub Form2_MouseMove(sender As Object, e As MouseEventArgs) Handles Me.MouseMove
        If MovBoll = True Then
            CurrX = Me.Left - MousX + e.X
            CurrY = Me.Top - MousY + e.Y
            Me.Location = New Point(CurrX, CurrY)
        End If
    End Sub

    Private Sub Form2_MouseUp(sender As Object, e As MouseEventArgs) Handles Me.MouseUp
        MovBoll = False
    End Sub
End Class

像这样可以直接复制,修改起来也不麻烦

在上图当中还有一个“更多功能”选项,这样就可以展开和收缩

If Me.Height = 348 Then
            Me.Height = 246
        Else
            Me.Height = 348
        End If

你可能感兴趣的:(vb.net,窗体活动,.net)