0
我開發了Windows窗體應用程序。我實現了禁用雙擊標題欄,並隱藏最大化和最小化按鈕。但單擊和移動光標導致窗口得到最小化。是否有任何方法來限制最小化窗口的任何方式。只有關閉標題欄上的按鈕應該工作。如何禁用單擊標題欄以限制窗口應用程序中的窗口最小化
我開發了Windows窗體應用程序。我實現了禁用雙擊標題欄,並隱藏最大化和最小化按鈕。但單擊和移動光標導致窗口得到最小化。是否有任何方法來限制最小化窗口的任何方式。只有關閉標題欄上的按鈕應該工作。如何禁用單擊標題欄以限制窗口應用程序中的窗口最小化
在窗體的proerpties中將controlbox設置爲false並將邊框樣式設置爲none,然後使您自己的按鈕關閉窗口。
如果您希望窗口可拖動,請使用我在很久以前在某處找到的代碼,並且無法回想起功勞。
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