Use GetSystemMenu to get the system menu's handle. Then use DeleteMenu to remove the menu items.
Note that removing these menu items disables the minimize and maximize buttons in the title bar, but it does not remove them.
This program uses a more general routine that allows you to remove any or all of the items from the system menu. Note that if you remove the Close command, you must provide the user with another way to close the form.
|
Private Sub Form_Load()
RemoveMenus Me, False, False, _
False, True, True, _
False, False
End Sub
Private Sub RemoveMenus(frm As Form, _
remove_restore As Boolean, _
remove_move As Boolean, _
remove_size As Boolean, _
remove_minimize As Boolean, _
remove_maximize As Boolean, _
remove_seperator As Boolean, _
remove_close As Boolean)
Dim hMenu As Long
' Get the form's system menu handle.
hMenu = GetSystemMenu(hwnd, False)
If remove_close Then DeleteMenu hMenu, 6, MF_BYPOSITION
If remove_seperator Then DeleteMenu hMenu, 5, _
MF_BYPOSITION
If remove_maximize Then DeleteMenu hMenu, 4, _
MF_BYPOSITION
If remove_minimize Then DeleteMenu hMenu, 3, _
MF_BYPOSITION
If remove_size Then DeleteMenu hMenu, 2, MF_BYPOSITION
If remove_move Then DeleteMenu hMenu, 1, MF_BYPOSITION
If remove_restore Then DeleteMenu hMenu, 0, _
MF_BYPOSITION
End Sub
|