VB - Disable the "X" of your form
This will disable the "X" of the window.
VB Code:
'in a module
Public Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
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 Declare Function DrawMenuBar Lib "user32" (ByVal hwnd As Long) As Long
Public Const MF_REMOVE = &H1000&
Public Const MF_INSERT = &H0&
Public Const MF_ENABLED = &H0&
Public Const MF_BYPOSITION = &H400&
Public Sub DisableX(frm As Form, blnDisabled As Boolean)
Dim hMenu As Long
Dim nCount As Long
If blnDisabled = True Then
hMenu = GetSystemMenu(frm.hwnd, 0)
nCount = GetMenuItemCount(hMenu)
Call RemoveMenu(hMenu, nCount - 1, MF_REMOVE Or MF_BYPOSITION)
Call RemoveMenu(hMenu, nCount - 2, MF_REMOVE Or MF_BYPOSITION)
DrawMenuBar frm.hwnd
Else
hMenu = GetSystemMenu(frm.hwnd, True)
DrawMenuBar frm.hwnd
End If
End Sub
Private Sub Form_Load()
' this goes in the form_load or a command button or something
Call DisableX(Me, True)
End Sub