Re: MDI - use same menu in the different views

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Frank Hickman (fhickman_nosp_at_m_noblesoft.com)
Date: 05/18/04

  • Next message: Drew Myers: "Re: Spin button problem"
    Date: Tue, 18 May 2004 12:06:18 -0400
    
    

    "stefkeB" <stefkeB@hotmail.com> wrote in message
    news:%23mdPL5KPEHA.2716@tk2msftngp13.phx.gbl...
    > I have an MFC MDI Doc/View Application, using only one document type, but
    > with different views. That is working fine.
    >
    > The way I do it now is to define a separate menu for all views in the
    > resource editor. That's fine (apart from some copy & paste) for most menus
    > but when I add a new menu entry at runtime it only get's connected to the
    > active view.
    >

    This is the correct behaviour. Each MDI view has it's own menu, changing
    one does not affect the others.

    > Is it best to:
    > a) add the new entry in a loop for all viewtypes? And if so, what when you
    > need to update the runtime-entries?
    >

    Since the menus are loaded when the views are loaded this would not work the
    way you want...unless you programatically change the menu resource before it
    is used.

    > b) share only one menu between the views? And if so, how do you do that?
    And
    > if you do that, will a new menu entry be added to all views when I add one
    > at runtime?
    >

    You can do this a couple (few) different ways. One way is to load a
    specific menu when the view is displayed in OnInitialUpdate. Remember
    however that menus are a resource of the frame so your view would need to
    use the frame window for the view. Another way would be to not create menu
    resources for each view but use the main menu for all views. Depending on
    the complexity of the menus, you may need to add a popup to the main menu
    for the currently displayed view. This can get complicated quickly.

    I don't exactly know what the conditions are for your problem but probably
    the easiest thing to do would be to create a standard "view" menu and load
    that one when your views are created.

    HTH

    -- 
    ============
    Frank Hickman
    NobleSoft, Inc.
    ============
    Replace the _nosp@m_ with @ to reply.
    

  • Next message: Drew Myers: "Re: Spin button problem"
  • Quantcast