Declare Function RemoveMenu Lib "user32.dll" (ByVal hMenu As Long, ByVal uPosition As Long, ByVal uFlags As Long) As Long
RemoveMenu removes an item from a menu. If the item being removed is a submenu, the submenu is not actually destroyed by this function. Instead, the submenu is simply removed from the menu, allowing your program to use the submenu elsewhere.
If successful, the function returns a non-zero value. If an error occured, the function returns zero (use GetLastError to get the error code).
None.
Const MF_BYCOMMAND = &H0
Const MF_BYPOSITION = &H400
Remove the "Maximize" and "Minimize" options from a form window's system menu. Note that doing this will not remove the maximize and minimize buttons on the window's title bar, although the buttons will stop working. In a real program, if you wanted to remove the minimize and maximize buttons from a window, the best way would be to do so before creating the window. To use this example, place a command button named cmdExample on a form window.
' This code is licensed according to the terms and conditions listed here.
' Declarations and such needed for the example:
' (Copy them to the (declarations) section of a module.)
Public Declare Function GetSystemMenu Lib "user32.dll" (ByVal hWnd As Long, ByVal bRevert As Long) As Long
Public Declare Function RemoveMenu Lib "user32.dll" (ByVal hMenu As Long, ByVal uPosition As Long, _
ByVal uFlags As Long) As Long
Public Const MF_BYCOMMAND = &H0
Public Const SC_MINIMIZE = &HF020
Public Const SC_MAXIMIZE = &HF030
' *** Place the following code inside the form window. ***
Private Sub cmdExample_Click()
Dim hSysMenu As Long ' handle to the window's system menu
Dim retval As Long ' return value of functions
' Get a handle to the window's system menu.
hSysMenu = GetSystemMenu(Me.hWnd, 0)
' Remove the minimize and maximize options, using their item IDs.
retval = RemoveMenu(hSysMenu, SC_MINIMIZE, MF_BYCOMMAND)
retval = RemoveMenu(hSysMenu, SC_MAXIMIZE, MF_BYCOMMAND)
End Sub
Back to the Function list.
Back to the Reference section.
Last Modified: December 17, 2000
This page is copyright © 2000 Paul Kuliniewicz.
Copyright Information Revised October 29, 2000
Go back to the Windows API Guide home page.
E-mail: vbapi@vbapi.com Send Encrypted E-Mail
This page is at http://www.vbapi.com/ref/r/removemenu.html