Solved

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

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Use Multiple Forms 4 48
VB 6.0 printer how to align 6 57
to transfer string from C lanaguage to VBA 4 56
Crystal reports - Formula Field code need assistance with code 17 51
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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

930 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

9 Experts available now in Live!

Get 1:1 Help Now