Click here to Skip to main content
Click here to Skip to main content

Dynamic submenus

, 20 Mar 2000
Rate this:
Please Sign up or sign in to vote.
Some handy functions for adding and deleting submenus and menuitems in runtime
  • Download demo project - 14 Kb
  • Download source files - 2 Kb
  • Sample Image - DynMenu.gif

    Here are some short handy functions for adding and deleting submenus and menu items in runtime.

    To add a menu with some items in the file menu at a specified index, use:

      MenuItemData data[] ={
        ID_COMMAND_1, "First Item",
        ID_COMMAND_2, "Second Item",
        0, NULL
      };
      CMenu *pMenu = AddSubMenu(pMainFrm, file_menu_index, sub_menu_index, "Dynamic Menu", data); 
    

    To append an item to the menu later on, use:

      AddSubMenuItem(pMenu, ID_COMMAND_3, "Third Item");
    

    To remove a submenu again, use:

      RemoveSubMenu(pMainFrm, file_menu_index, sub_menu_index);
    

    To remove only one item, use:

      RemoveSubMenuItem(pMenu, ID_COMMAND_1);
    

    That's all. Enjoy!

    License

    This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

    A list of licenses authors might use can be found here

    Share

    About the Author

    Anneke Sicherer-Roetman
    Web Developer
    Netherlands Netherlands
    No Biography provided

    Comments and Discussions

     
    QuestionHow can I change a submenus caption at runtime? Pinmemberrajksingh30-Oct-03 20:19 
    GeneralThe one error I get. PinmemberDarroll28-Sep-02 21:30 
    GeneralCDialog versio, how to here PinmemberDarroll28-Sep-02 21:28 
    GeneralStatic Resource ID PinsussAnonymous12-Aug-02 17:03 
    GeneralRe: Static Resource ID PinmemberDarroll28-Sep-02 21:21 
    QuestionCreating view menu and sub menu? PinmemberWilson5-Aug-01 23:08 
    QuestionCreating view menu and sub menu? PinmemberWilson5-Aug-01 23:08 
    Questionwhat's function AddSubMenu, AddSubmenuItem? Pinmemberdmz30-Jul-01 3:35 
    GeneralFirst submenu PinmemberSPT16-Jul-01 11:40 
    GeneralRe: First submenu PinmemberAnneke Sicherer-Roetman16-Jul-01 22:28 
    QuestionOut of topic... - How to disable/gray/enable normal menu item? PinsussMartin Vrbovsky6-Oct-00 2:58 
    AnswerRe: Out of topic... - How to disable/gray/enable normal menu item? PinmemberMartin Vrbovsky16-Dec-01 16:15 
    AnswerRe: Out of topic... - How to disable/gray/enable normal menu item? PinmemberRoman1982Murk6-Sep-07 15:23 

    General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

    Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

    | Advertise | Privacy | Terms of Use | Mobile
    Web01 | 2.8.141223.1 | Last Updated 21 Mar 2000
    Article Copyright 2000 by Anneke Sicherer-Roetman
    Everything else Copyright © CodeProject, 1999-2014
    Layout: fixed | fluid