Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Visual Basic (Microsoft) Versions 5/6 FAQ


How do you change the system menu (on the Control-Menu Box)? by Michael42
Posted: 13 Feb 03

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.

Back to Visual Basic (Microsoft) Versions 5/6 FAQ Index
Back to Visual Basic (Microsoft) Versions 5/6 Forum

My Archive

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close