Solved

VB6 Menu Problem

Posted on 2003-10-29
11
1,280 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
Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

 
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

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

789 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