devxlogo

Disable the Standard Window Close (X) Button

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
See also  Why ChatGPT Is So Important Today
devxblackblue

About Our Editorial Process

At DevX, we’re dedicated to tech entrepreneurship. Our team closely follows industry shifts, new products, AI breakthroughs, technology trends, and funding announcements. Articles undergo thorough editing to ensure accuracy and clarity, reflecting DevX’s style and supporting entrepreneurs in the tech sphere.

See our full editorial policy.

About Our Journalist