include("../include.php"); writeHeader("Disable the close button", "Programming » Visual Basic 6 » Visual Basic 6 Code » Forms » ");?>
Public Declare Function GetSystemMenu Lib "user32" _ (ByVal hwnd As Long, _ ByVal bRevert As Long) As Long Public Declare Function GetMenuItemCount Lib "user32" _ (ByVal hMenu As Long) _ As Long Public Declare Function RemoveMenu Lib "user32" _ (ByVal hMenu As Long, ByVal _ nPosition As Long, ByVal wFlags As Long) As Long Public Declare Function DrawMenuBar Lib "user32" _ (ByVal hwnd As Long) As Long Public Const MF_BYPOSITION = &H400& Public Const MF_REMOVE = &H1000& Public Sub DisableX(Frm As Form) Dim hMenu As Long Dim nCount As Long hMenu = GetSystemMenu(Frm.hwnd, 0) nCount = GetMenuItemCount(hMenu) 'Get rid of the Close menu and its separator Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION) Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION) 'Make sure the screen updates 'our change DrawMenuBar Frm.hwnd End Sub