Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Here's a API function the Disables the Close button. 2

Status
Not open for further replies.

MrVB50au

Programmer
Mar 16, 2003
326
0
0
AU
The following disables the close button on a MDIForm but can be used for any other form as well.

Option Explicit

Const MF_BYPOSITION = &H400

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 Sub MDIForm_Load()
RemoveMenu GetSystemMenu(Me.hWnd, 0), 6, MF_BYPOSITION
End Sub
 
Thats a very useful post, and it works great!!
A star for you!
 
Just a small note to remember about doing this:
just because the close menu is disabled does not mean that a user cannot close the form down without clicking on some special button or link.
If you press ALT+F4 the form will still close down, you will need to trap for this in the form KeyDown event.

Gavin
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top