Strange & irritating behavior of MDI-Child (child menu replaces MDI menu) ...


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 8 of 8

Thread: Strange & irritating behavior of MDI-Child (child menu replaces MDI menu) ...

Hybrid View

  1. #1
    Join Date
    Jun 2006
    Posts
    29

    Strange & irritating behavior of MDI-Child (child menu replaces MDI menu) ...

    Hello!

    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.

    Waiting for your vaulable reply ...

    Thanks & Regards,

    Ruturaj.

  2. #2
    Join Date
    Dec 2005
    Posts
    92
    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.

  3. #3
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    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.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  4. #4
    Join Date
    Jun 2006
    Posts
    29
    Quote Originally Posted by Phil Weber
    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!

    What you think of using SetParent API?

  5. #5
    Join Date
    Dec 2005
    Location
    South of Nowhere, Maine
    Posts
    309
    You lose some of your MDI/Child functionality that way.

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

  6. #6
    Join Date
    Jun 2006
    Posts
    29
    Quote Originally Posted by edburdo
    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.

    Best Regards,

    Ruturaj.

  7. #7
    Join Date
    Nov 2003
    Location
    Portland, OR
    Posts
    8,387
    FYI, you can move a menu from one form to another by opening the .frm files in a text editor and copying and pasting the menu controls.
    Phil Weber
    http://www.philweber.com

    Please post questions to the forums, where others may benefit.
    I do not offer free assistance by e-mail. Thank you!

  8. #8
    Join Date
    Jun 2006
    Posts
    29
    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?
    Last edited by vb_programmer; 08-15-2006 at 04:28 PM.

Similar Threads

  1. Replies: 1
    Last Post: 03-07-2006, 06:49 PM
  2. Replies: 0
    Last Post: 04-10-2001, 09:54 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center