Disable the Standard Window Close (X) Button

This code disables the standard Window Close (X) button on the upper right corner of Windows forms:

Private Const SC_CLOSE As Integer = &HF060Private Const MF_GRAYED As Integer = &H1 Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As LongPrivate Declare Function EnableMenuItem Lib "user32" (ByVal hMenu As Long, ByVal wIDEnableItem As Long, ByVal wEnable As Long) As Long  Private  Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs)   EnableMenuItem(GetSystemMenu(Me.Handle, False), SC_CLOSE, MF_GRAYED)End Sub
Share the Post:
Share on facebook
Share on twitter
Share on linkedin


Recent Articles: