I found this code over the internet but am unsure about how to use it. Also I need to enable it back after work is complete. Help please.
Private Const CP_NOCLOSE_BUTTON As Integer = &H200
Protected Overloads Overrides ReadOnly Property CreateParams() As CreateParams
Get
Dim myCp As CreateParams = MyBase.CreateParams
myCp.ClassStyle = myCp.ClassStyle Or CP_NOCLOSE_BUTTON
Return myCp
End Get
End Property
You would paste this into your form’s code to use it. This however permanently disables the close button. Doing it dynamically requires very different code, you have to modify the system menu. Paste this code into your form and use the CloseEnabled property in your logic: