This is how to DISABLE it,,,
Put this in a module in the General Declarations of a Module
http://www.vbcity.com/forums/faq.asp...Forms#TID16114Code:Code: Public Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert 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 Const MF_BYPOSITION = &H400& Put this in a Module so that it can be accessed by different Forms Code: Public Sub DisableCloseWindowButton(frm As Form) Dim hSysMenu As Long 'Get the handle to this windows system menu hSysMenu = GetSystemMenu(frm.hwnd, 0) 'Remove the Close menu item This will also disable the close button RemoveMenu hSysMenu, 6, MF_BYPOSITION 'Lastly, we remove the seperator bar RemoveMenu hSysMenu, 5, MF_BYPOSITION End Sub Call the Function in the Form_Load Event of a form as follows: Code: Private Sub Form_Load() DisableCloseWindowButton Me End Sub




Reply With Quote