Link to home
Start Free TrialLog in
Avatar of Zukes
Zukes

asked on

VB6 Menu Problem

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
SOLUTION
Avatar of fantasy1001
fantasy1001

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zukes
Zukes

ASKER


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?

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 ~
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Zukes

ASKER


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)
Avatar of Zukes

ASKER


I've split points based on how much your comments prompted me to solve this.
Thanks & regards,
Zukes
Zukes,
Thanks for the points!!!  DOn't worry about wasting my time.  It is all learning to me.
Thanks for the points... was glad to help.