
Disabling "close button" in a form
This requires removing the close from the system menu, and forcing a menubar redraw. The
API and constants can be found in the API viewer....
Private Sub Command5_Click()
Dim hMenu As Long
Dim MenuItems As Long
Dim r As Long
hMenu = GetSystemMenu(Form1.hwnd, 0)
MenuItems = GetMenuItemCount(hMenu)
'remove the system menu separator line
r = RemoveMenu(hMenu, MenuItems - 1, MF_REMOVE Or MF_BYPOSITION)
'remove the system menu Close menu item
r = RemoveMenu(hMenu, MenuItems - 2, MF_REMOVE Or MF_BYPOSITION)
'force a redraw of the menu,
'this also refreshes the caption, dimming the X
r = DrawMenuBar(Form1.hwnd)
End Sub
--
Randy Birch, MVP Visual Basic
VBnet, The Visual Basic Developers Resource Centre
http://home.sprynet.com/sprynet/rasanen/vbnet/default.htm
:Please help!!!!!!!
:How can I disable that X in upper-right corner of a form but leaving the
:Minimize button enabled & visible??
:
:Thanx in advance, Ike
:
:--
:ICQ: 8679454
:
: