I am using this code to disable the "X" (close) control on a .Net 2.0 form, but is there a better way? I'd rather use code from the .Net framework instead of VB6 code.
tia,
flynn
Code:
Public Class Form1
Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Integer, ByVal bRevert As Integer) As Integer
Public Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer
Public Const SC_CLOSE = &HF060&
Public Const MF_BYCOMMAND = &H0&
Private Sub Form1_Activated(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Activated
Dim SysMenuHandle As Integer
SysMenuHandle = GetSystemMenu(Me.Handle().ToInt32(), False)
RemoveMenu(SysMenuHandle, SC_CLOSE, MF_BYCOMMAND)
End Sub
End Class
tia,
flynn