strongm is very right in his statment and I fully agree with him. It is better to either remove, or disable the X button instead of having it there enabled but functionless.
The "Remove/Disable X Button" problem is one of the most popular questions asked on this forum atleast once a month and you may find many threads including thread222-662889 and thread222-523899 if you search this forum.
But don't visit these threads; let me post the solution once more.
![[smile] [smile] [smile]](/data/assets/smilies/smile.gif)
___
[tt]
Option Explicit
Private Declare Function GetSystemMenu Lib "user32" (ByVal hwnd As Long, ByVal bRevert As Long) As Long
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Const MF_BYPOSITION = &H400&
Private Sub Form_Load()
Dim hSysMenu As Long
'get a handle to the system menu.
hSysMenu = GetSystemMenu(hwnd, 0)
'remove the 6th menu item from the system menu
'which is the "Close" command.
'note that this index is zero-based.
RemoveMenu hSysMenu, 6, MF_BYPOSITION
'removing the Close command disables
'the 'X' on the title bar as well!
'remove the 5th menu item which is the seperator bar.
RemoveMenu hSysMenu, 5, MF_BYPOSITION
End Sub
[/tt]