Visual Basic Code of the Week (COTW)
http://www.codeoftheweek.com
Issue #108
Online Version at http://www.codeoftheweek.com/membersonly/bi/0108.html (paid subscribers only)
All content and source code is Copyright (c) 1999 by C&D Programming Corp. No part of this issue can be reprinted or distributed in any manner without express written permission of C&D Programming Corp.

Issue topic: Removing items from the System Menu

Get paid to surf the web!

If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Six months of VB Training for only $49.99

Want to get up to speed on the latest Visual Basic programming? Includes Visual Basic 6 and Visual InterDev 6. Check out our training programs at http://www.codeoftheweek.com/vbtraining.html

Requirements

In this Issue

In this issue we discuss how to remove items from the system menu.

If you have any questions about using this module, let us know at questions@codeoftheweek.com

basFormUtils

The basFormUtils module contains a method which allows you to remove any option from the system menu of a Visual Basic form. It provides these features using two API calls: GetSystemMenu and RemoveMenu. The GetSystemMenu retrieves the handle to the system menu of the specified window. The RemoveMenu call is the one that actually removes the menu item from the menu.

Methods

Public Sub RemoveSystemMenu(ByVal frm As Form, ByVal eMenu As enumMenuType)

This method will remove the system menu item on the form specified by frm. The menu item is defined by the enumerator enumMenuType. The valid choices for eMenu are mtMove, mtSize, mtMinimize, mtMaximize, mtClose, mtRestore. Each enumerator will remove the associated menu option. For example, if you specify the mtMove enumerator it will remove the Move option from the system menu.

Sample Usage

The below sample shows how to call the RemoveSystemMenu method with various options. In this particular example it will remove the maximize, restore and size options from the system menu. You would typically call this method from the Form_Load method within your form.

Private Sub Form_Load()
    RemoveSystemMenu Me, mtMaximize
    RemoveSystemMenu Me, mtSize
    RemoveSystemMenu Me, mtRestore
End Sub

Source Code

To see the source code for this issue you must be a subscriber to Code of the Week. If you are a subscriber the source code is available at the following address: http://www.codeoftheweek.com/membersonly/bi/0108.html


This document is available on the web

Paid subscribers can view this issue in HTML format. There is no additional source or information in the HTML formatted document. It just looks a little better since we have included some HTML formatting. Just point your browser to link at the top of this document.

Get paid to surf the web!

If you would like to get paid for surfing the web, jump to http://www.codeoftheweek.com/paidsurf.html

Other links

Contact Information

C&D Programming Corp.
PO Box 20128
Floral Park, NY 11002-0128
Phone or Fax: (212) 504-7945
Email: info@codeoftheweek.com
Web: http://www.codeoftheweek.com