Click here to Skip to main content
Licence 
First Posted 20 Mar 2000
Views 114,868
Bookmarked 25 times

Dynamic submenus

By | 20 Mar 2000 | Article
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

    About the Author

    Anneke Sicherer-Roetman

    Web Developer

    Netherlands Netherlands

    Member



    Sign Up to vote   Poor Excellent
    Add a reason or comment to your vote: x
    Votes of 3 or less require a comment

    Comments and Discussions

     
    You must Sign In to use this message board. (secure sign-in)
     
    Search this forum  
     FAQ
        Noise  Layout  Per page   
      Refresh
    QuestionHow can I change a submenus caption at runtime? Pinmemberrajksingh19:19 30 Oct '03  
    GeneralThe one error I get. PinmemberDarroll20:30 28 Sep '02  
    GeneralCDialog versio, how to here PinmemberDarroll20:28 28 Sep '02  
    GeneralStatic Resource ID PinsussAnonymous16:03 12 Aug '02  
    GeneralRe: Static Resource ID PinmemberDarroll20:21 28 Sep '02  
    QuestionCreating view menu and sub menu? PinmemberWilson22:08 5 Aug '01  
    QuestionCreating view menu and sub menu? PinmemberWilson22:08 5 Aug '01  
    Questionwhat's function AddSubMenu, AddSubmenuItem? Pinmemberdmz2:35 30 Jul '01  
    GeneralFirst submenu PinmemberSPT10:40 16 Jul '01  
    GeneralRe: First submenu PinmemberAnneke Sicherer-Roetman21:28 16 Jul '01  
    QuestionOut of topic... - How to disable/gray/enable normal menu item? PinsussMartin Vrbovsky1:58 6 Oct '00  
    AnswerRe: Out of topic... - How to disable/gray/enable normal menu item? PinmemberMartin Vrbovsky15:15 16 Dec '01  
    AnswerRe: Out of topic... - How to disable/gray/enable normal menu item? PinmemberRoman1982Murk14:23 6 Sep '07  

    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.

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