Solved

VB6 Menu Problem

Posted on 2003-10-29
11
1,272 Views
Last Modified: 2011-09-20
Background:
In my VB6 MDI application, the MDI form has quite a few menus. There are 10 main menus, each with up to 8 or so submenus. In several places, some of those submenus contain submenus of their own. So at most the menus nest to three levels.
When the user selects a menu item, I disable certain other menu items that can't be available while the user is "in" the menu (most of the menus open a child form). When the user closes from the form involved, I enable the menus I disabled. It can get quite complex because when one menu is entered, several get disabled, but there are others that remain available. If the user selects one of those, I disable the appropriate items for that selection, taking into account whether they have been disabled by a previous selection. I accomplish this with a dynamic array that keeps track of what menus are disabled by what other menus. It all works really well.
However I have a problem. Sometimes I run into a runtime error because you can't disable all of the visible submenus for a menu. It makes sense, of course, otherwise you could choose a menu and see all disabled options, which isn't good form.
My latest solution is to model the menu structure completely in an array. I perform the changes on the array when enabling/disabling menus, then check for the error situation and disable the parent menu if all of its submenus are disabled. I then have to carefully apply the changes from the array to the actual menus on the form. The best I can do has me looping through all those menus 3 times. This is because I can't disable all submenus and then disable the parent menu. I have to do the parent(s) first. All in all, it is too complex, slow and isn't satisfactory.

Questions:
1. Anyone had this problem before? Is there a "standard" solution to this I have never seen?
2. Should I go entirely another way? - I've been toying with generating the entire menu structure dynamically at runtime - that way, instead of enabling/disabling menu items, I can re-generate only the available ones. Doesn't sound very GUI-compliant, though.
3. Anyone know of a robust active-x menu control that doesn't have this limitation? (this is a commercial app I'm writing, the component has to be tried and tested).
Thanks
Zukes
0
Comment
Question by:Zukes
  • 3
  • 3
  • 2
  • +2
11 Comments
 
LVL 5

Assisted Solution

by:fantasy1001
fantasy1001 earned 50 total points
ID: 9648355
Why don't set the popup form in modal mode, in which the user cannot access at all the menu,
0
 

Assisted Solution

by:clangl
clangl earned 50 total points
ID: 9649679
Can you instead of disabling them make the visible property false?  Just a thought.
0
 
LVL 9

Assisted Solution

by:Dang123
Dang123 earned 100 total points
ID: 9650038

I forget where I read it, but a few people suggest not disabling menu options, instead put up a message box when a menu item is used when it shouldn't be. The message box should describe when the item is really available. This is supposed to prevent confusion for the non PC-literate as the menu system won't change constantly and the user can find out exactly how to get a menu item active ( A quote from one of my users trying Word went something like this once "Now why can't I cut this paragraph!!?? My blinking thing is in it!!!")

Doing this, would also prevent your problem of having all menu items disabled in any given sub menu. You said you are already keeping any array that indicates if a menu item should be enabled or not, use it to check if the message box should come up or the function should be called.
0
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
LVL 3

Accepted Solution

by:
ashoooo earned 300 total points
ID: 9653122
Disabling the parent menu is not a good idea. And its not standard too.
0
 

Author Comment

by:Zukes
ID: 9654629

Hmmm. Ashoooo, I just ran a few office apps and the VB IDE. You are right... I can see instances where a menu is available and all of its submenus are disabled. If Microsoft does it, it must be ok (!). Why have they built in this dumb rule into their menu control? I guess that means I need another menu control?

0
 
LVL 5

Expert Comment

by:fantasy1001
ID: 9654773
In term of MDI, when there is a parent menu which is on the mdi form, if we also add a menu into the child, when the child active, it will use the child menu.

For your case, you can create the menu for each child, for example, when you are creating the menu for the child, then disable directly the menu you don't want. Get it??

Thanks
~ fantasy ~
0
 
LVL 3

Assisted Solution

by:ashoooo
ashoooo earned 300 total points
ID: 9655572
Zukes, I guess the menu isnt disabled even though the children are disabled is because so that the user knows that these submenus 'might' be available at a later stage.

You can selectively disable the child menus and keep the parent enabled.
0
 

Author Comment

by:Zukes
ID: 9656062

Folks, I've messed up.
I've found the problem and it wasn't what I thought.
I can disable all the submenus for a menu and leave the parent enabled.
I didn't investigate the problem enough.
The runtime error occurs when I try to disable a MENU BAR.
I'm sorry to have wasted your time on this.

I will contact the Experts Exchange co-ordinator and see how allocate points
on this. I shall allocate some.
Sorry to have wasted your time and thanks for the comments.

Regards
Zukes (The Unthorough)
0
 

Author Comment

by:Zukes
ID: 9656160

I've split points based on how much your comments prompted me to solve this.
Thanks & regards,
Zukes
0
 

Expert Comment

by:clangl
ID: 9656724
Zukes,
Thanks for the points!!!  DOn't worry about wasting my time.  It is all learning to me.
0
 
LVL 3

Expert Comment

by:ashoooo
ID: 9658705
Thanks for the points... was glad to help.
0

Featured Post

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Vb.net 2008 2 60
Adding to a VBA? 6 70
VBA Shell can't Find Word document 11 94
Add and format columns in vb6 7 57
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…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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 process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

810 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