Solved

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

Posted on 2002-07-15
1
208 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

776 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