
Public Function DisableClose(ByVal hwnd, Optional ByVal MDIChild As Boolean)
Dim hSysMenu As Long
Dim nCnt As Long
Dim cID As Long
hSysMenu = GetSystemMenu(hwnd, False)
If hSysMenu = 0 Then Exit Function
nCnt = GetMenuItemCount(hSysMenu)
If MDIChild Then
cID = 3
Else
cID = 1
End If
If nCnt Then
DisableClose = RemoveMenu(hSysMenu, nCnt - cID, MF_BYPOSITION Or MF_REMOVE)
DisableClose = RemoveMenu(hSysMenu, nCnt - cID - 1, MF_BYPOSITION Or MF_REMOVE)
nCnt = GetMenuItemCount(hSysMenu)
DisableClose = DeleteMenu(hSysMenu, nCnt - 1, MF_BYPOSITION)
nCnt = GetMenuItemCount(hSysMenu)
DisableClose = DeleteMenu(hSysMenu, nCnt - 1, MF_BYPOSITION)
End If
End Function
Dim hSysMenu As Long
Dim nCnt As Long
Dim cID As Long
hSysMenu = GetSystemMenu(hwnd, False)
If hSysMenu = 0 Then Exit Function
nCnt = GetMenuItemCount(hSysMenu)
If MDIChild Then
cID = 3
Else
cID = 1
End If
If nCnt Then
DisableClose = RemoveMenu(hSysMenu, nCnt - cID, MF_BYPOSITION Or MF_REMOVE)
DisableClose = RemoveMenu(hSysMenu, nCnt - cID - 1, MF_BYPOSITION Or MF_REMOVE)
nCnt = GetMenuItemCount(hSysMenu)
DisableClose = DeleteMenu(hSysMenu, nCnt - 1, MF_BYPOSITION)
nCnt = GetMenuItemCount(hSysMenu)
DisableClose = DeleteMenu(hSysMenu, nCnt - 1, MF_BYPOSITION)
End If
End Function