Reputation: 379
I have developed windows form application. I achieved disabling double clicking on title bar and also hid maximize and minimize buttons.But single clicking and moving cursor causing window to get minimized.Is there any way to restrict minimizing the window by any way.Only close button on title bar should work.
Upvotes: 0
Views: 545
Reputation:
on the form proerpties set controlbox to false and form border style to none, then make your own button to close the window.
If you want the window to be draggable, use this code I found somewhere long ago and cannot recall to give credit.
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
Upvotes: 0