If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

I'm facing some strange and irritating behavior of MDI & Child form regarding the Form menu. In my application, I have one MDI form and one Child form. I have defined an Object As ChildForm and create multiple instances of this child form as and when required.

This Child Form has a Listview that needs to show a Popup menu. So, I have created this Popup menu on the ChildForm itself and made it Visible = False. Till today, client did not demand any menu on MDI form; however as per his specifications, I need to add some menu items on MDI form as well.

The problem is ... when the ChildForm is loaded, MDI Form menu is lost! This might be due to the fact that ChildForm itself is having a menu on it (the hidden menu created for Listview Popup menu). This hidden menu from ChildForm actually takes place on the Application's menu bar and hence MDI Form's own menu goes for a walk! I don't understand why this behavior; but I guess this might be the case.

There is a certain option open for me ... shift the whole ChildForm menu (which is Visible = False) to MDI form and call it on Listview as PopupMenu frmMDI.MyPopupMenu; but there are in fact two Menu with manu sub-menu items. Plus, the complete referencing throughout the project code for these Menu items and subitems will be needed to be checked ... and also the menu handling code will be needed to be moved to MDI form. The code has some local references to ChildForm and other components on it; hence all these References will also be needed to be revisited with frmMDI.ActiveForm replacements! Huh, a lot of work it will be!

Is there any work-around for this MDI-Child behavior? Can I have the MDI Form menu as is; even though the ChildForm is having few menu items on it? Please let me know if you know any solution for this.

Ruturaj,it seems you already know what you need to do,but you're merely asking for confirmation.Yes,you've to shift the child-form's menu to the MDI parent.The in-built behaviour is that the former's menu will eliminate the latter's.

Another option is to put the popup menus on another form which is not an MDI child. Or use a third-party component (like this one) to create the menus at runtime.

Thanks for your reply. Instead of moving the menu (and hence the code to handle that menu item) to MDI, I was thinking of some other solution. I was thinking of making the current ChildForm's MDIChild = False and then use SetParent API to make it a child form. I have not tried it yet; just gathered the information on SetParent API and was thinking to try it. I guess this will not vanish the MDI form's menu even though the ChildForm is having menu.

But I'm afraid that it should not create any trouble in future regarding any Subclassing or anything that I have already implemented. I also need to implement Explorer's Shell Contenxt menu in the same code in coming few days. I know both these issues are completely different; still VB requires nothing to create API conflict and crash the IDE ... that way it's really quite vulnerable!

Is there some reason that you can't just move the menus to the parent form and show/hide them as needed?

Unfortunately VB Menu maker does not have any Save and Import menu feature. Hence, when we say "move a menu from one form to another" it's actually a lot of donkey-work, especially when the menu is large with lot of submenu items. (BTW, do you know any plug-in that will facilitate the menu structure save and import feature?)

Secondly, it's my mistake that I have not written a central Menu handler function; hence every menu has it's Click event code written on its own click event. Needless to say, either I will also need to carry this menu click code to the MDI or collect the menu click event code in a single central function, may be written on the ChildForm itself and calling it from MDI menu as frmMDI.ActiveForm.HandlePopupMenu(sMenuKey). Currently, I have made-up my mind to go with the second option. I'm just collecting the whole menu handling code into one single Public Sub and then later I will "move" the menu to MDI.

Actually, the application was never intended to be a MDI application; hence I did not take care of MDI-Child related issues while designing & developing this application! Anyways. Hence, I was looking out for some tricky solution that will help me out. Once I thought of using some external Popup maker DLL or VB Class that will create Popup menu dynamically. I looked at vbAccelerator's Popup menu control, as always happens, I did not dare to implement such an "advanced" and heavily coded control in my Intermediate level application code!!!

I'm thankful to you for showing interest in my query and helping me to find a way-out.

Hmm, ok. I have not done this before; I will try. (of course, first I will create a backup of original source code though! )

BTW, Phil, I just visited your site; do you use any specific Blog program? I was always looking for a Blog that will allow me to specify HTML in Blog so then I will be able to provide HTML code for colour coded VB code in my Blog entry; and I saw you have it!! Have you developed it on your own or any other Open Source Code PHP based program?