Solved

Disabling some items in the system menu of the MDI Child form

Posted on 2002-07-15
1
206 Views
Last Modified: 2008-02-20
Hi,
I need to disable the next (CTRL+F6) that comes up in the system menu of a MDI child form. Hoe do I do it?
0
Comment
Question by:VCGuru
1 Comment
 
LVL 4

Accepted Solution

by:
AlonHirsch earned 75 total points
ID: 7153685
I haven't tried this for the 'Next' menu option, but you can :
The easiset way is to remove the menu option from the system menu.

You need the following API declarations :
Private Declare Function RemoveMenu Lib "user32" (ByVal hMenu As Long, ByVal nPosition As Long, ByVal wFlags As Long) As Long
Private Declare Function GetMenuItemCount Lib "user32" (ByVal hMenu As Long) As Long
Private Declare Function GetSystemMenu Lib "user32" (ByVal hWnd As Long, ByVal bRevert As Long) As Long

and the following constants :
Private Const MF_BYPOSITION = &H400&
Private Const MF_REMOVE = &H1000&

Then, the following code will remove the menu item :
Public Sub RemoveSystemLastItem(frm As Form)
    Dim hMenu As Long
    Dim itemCount As Long
   
    ' get the handle of the system menu
    hMenu = GetSystemMenu(frm.hWnd, 0)
    ' get the number of items in the menu
    itemCount = GetMenuItemCount(hMenu)
    'remove the system menu Close menu item
    RemoveMenu hMenu, itemCount - 1, MF_REMOVE Or MF_BYPOSITION
    'remove the system menu separator line
    RemoveMenu hMenu, itemCount - 2, MF_REMOVE Or MF_BYPOSITION
End Sub

This will physically remove the last item on the system menu as well as the seperator just above it.

I use this code to remove the Close menu option.

HTH,
Alon
0

Featured Post

Top 6 Sources for Identifying Threat Actor TTPs

Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

Join & Write a Comment

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

760 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now