如何禁用单击标题栏以限制Windos表单应用中最小化窗口



我已经开发了Windows表单应用程序。我实现了双击标题栏的双击,并掩盖了最大化和最小化按钮。但是单击和移动光标会导致窗口最小化。

在表单proerpties set controlbox上的false set controlbox to false,并形成边框样式,然后制作自己的按钮以关闭窗口。

如果您希望窗口可拖动,请使用我很久以前发现的此代码,并且无法回忆起信用。

Dim drag As Boolean
Dim mousex As Integer
Dim mousey As Integer
Private Sub mainform_MouseDown(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseDown
    drag = True 'Sets the variable drag to true.
    mousex = Windows.Forms.Cursor.Position.X - Me.Left 'Sets variable mousex
    mousey = Windows.Forms.Cursor.Position.Y - Me.Top 'Sets variable mousey
End Sub
Private Sub mainform_MouseMove(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseMove
    'If drag is set to true then move the form accordingly.
    If drag Then
        Me.Top = Windows.Forms.Cursor.Position.Y - mousey
        Me.Left = Windows.Forms.Cursor.Position.X - mousex
    End If
End Sub
Private Sub mainform_MouseUp(ByVal sender As Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles Me.MouseUp
    drag = False 'Sets drag to false, so the form does not move according to the code in MouseMove
End Sub

最新更新