Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleRemove the Minimize and Maximize buttons from a form's system menu
DescriptionThis example shows how to remove the Minimize and Maximize buttons from a form's system menu in Visual Basic 6. The program uses GetSystemMenu to get the system menu's handle and uses DeleteMenu to remove specific items.
Keywordsminimize, maximize, system menu
CategoriesControls, Tips and Tricks, API
 
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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated