Click here to Skip to main content
11,494,809 members (63,650 online)
Click here to Skip to main content

Dynamic submenus

, 20 Mar 2000 123.7K 3.4K 26
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? Pin
    rajksingh30-Oct-03 20:19
    memberrajksingh30-Oct-03 20:19 
    GeneralThe one error I get. Pin
    Darroll28-Sep-02 21:30
    memberDarroll28-Sep-02 21:30 
    GeneralCDialog versio, how to here Pin
    Darroll28-Sep-02 21:28
    memberDarroll28-Sep-02 21:28 
    GeneralStatic Resource ID Pin
    Anonymous12-Aug-02 17:03
    sussAnonymous12-Aug-02 17:03 
    GeneralRe: Static Resource ID Pin
    Darroll28-Sep-02 21:21
    memberDarroll28-Sep-02 21:21 
    QuestionCreating view menu and sub menu? Pin
    Wilson5-Aug-01 23:08
    memberWilson5-Aug-01 23:08 
    QuestionCreating view menu and sub menu? Pin
    Wilson5-Aug-01 23:08
    memberWilson5-Aug-01 23:08 
    Questionwhat's function AddSubMenu, AddSubmenuItem? Pin
    dmz30-Jul-01 3:35
    memberdmz30-Jul-01 3:35 
    GeneralFirst submenu Pin
    SPT16-Jul-01 11:40
    memberSPT16-Jul-01 11:40 
    GeneralRe: First submenu Pin
    Anneke Sicherer-Roetman16-Jul-01 22:28
    memberAnneke Sicherer-Roetman16-Jul-01 22:28 
    QuestionOut of topic... - How to disable/gray/enable normal menu item? Pin
    Martin Vrbovsky6-Oct-00 2:58
    sussMartin Vrbovsky6-Oct-00 2:58 
    AnswerRe: Out of topic... - How to disable/gray/enable normal menu item? Pin
    Martin Vrbovsky16-Dec-01 16:15
    memberMartin Vrbovsky16-Dec-01 16:15 
    AnswerRe: Out of topic... - How to disable/gray/enable normal menu item? Pin
    Roman1982Murk6-Sep-07 15:23
    memberRoman1982Murk6-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
    Web04 | 2.8.150520.1 | Last Updated 21 Mar 2000
    Article Copyright 2000 by Anneke Sicherer-Roetman
    Everything else Copyright © CodeProject, 1999-2015
    Layout: fixed | fluid