menu suggestion

2004-12-05
2013-04-15
  • moswald0000
    moswald0000
    2004-12-05

    Hi again.  :)

    I find myself doing a couple of things quite often.

    ** Firstly, I have a lot of pieces of code that look like this:

    menu<owned> m(ID_MYMENU);
    menu<shared> popup(m.sub_menu(0));
    ... // stuff, possibly modifying menu items
    popup.run_popup(...);

    It would be nice if I didn't have to create two menu items.  Lots of times I find myself making both objects menu<shared>, which causes a slow resource leak.  What I'd prefer is if run_popup took one extra parameter - the index of the sub menu to display as the popup.  For example,

    menu<owned> m(ID_MYMENU);
    m.run_popup(0, etc...);

    ** The second thing I do often is modify menu items.  I change things such as "show window" into "hide window", etc.  The code looks like this:

    menuitem_info mii = popup.item_byid(IDM_SHOWWINDOW).text(mbShow ? "Hide &Window" : "Show &Window");
    popup.item_byid(IDM_SHOWWINDOW, mii);

    It would make things *much* easier on us menu-editing-types if we could do some in-place menu editing.  Maybe an operator[] that takes a menu item id (throwing an exception if the id is invalid), or something of that nature.

    Thanks for your time, I know this was a long post.  :)

    --m

     
    • John Torjo
      John Torjo
      2004-12-07

      You're right.

      I have to make it easier not to mistakenly use menu<shared>, when you actually need menu<owned>.

      Soon I'll introduce Resource Splitter, where you'll be able to say something like:

      menu<owned> m(menu_::mymenu);

      Perhaps I can modify the syntax so that you simply can't say:

      menu<shared> m(menu_::mymenu);

      Best,
      John