Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you change the system menu (on the Control-Menu Box)?

API

How do you change the system menu (on the Control-Menu Box)?

by  Michael42  Posted    (Edited  )
You can turn off the minimize and maximize menu options by changing properties, but what if you're doing something critical in your VB program that should not be interrupted and you need to remove the "close" option?

Make the following declares:

Declare Function GetSystemMenu Lib "User" (ByVal hWnd As Integer, ByVal bRevert As Integer) As Integer
Declare Function RemoveMenu Lib "User" (ByVal hMenu As Integer, ByVal nPosition As Integer, ByVal wFlags As Integer) As Integer

Global Const MF_BYPOSITION=&H400

Use the following in your code to remove the "close" option:

SystemMenu% = GetSystemMenu (hWnd, 0)
Res% = RemoveMenu(SystemMenu%,6, MF_BYPOSITION)
Res% = RemoveMenu(SystemMenu%,6, MF_BYPOSITION) 'also remove the separator line

Check out the GetMenuID and InsertMenu API functions to do more complicated tasks.
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top