Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Change menu name on run-time

Change menu name on run-time

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestiontutorial
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    whofmans
    wrote on last edited by
    #1

    Hello! How can i change a menu name on runtime. With the menu-name i mean by example "File", "Edit" or "Help". Submenu's is not a problem for me because they have a ResourceID, but the menu's that i want to change on runtime does not have that, or i can't find them? Thanks for helping me.

    R R 2 Replies Last reply
    0
    • W whofmans

      Hello! How can i change a menu name on runtime. With the menu-name i mean by example "File", "Edit" or "Help". Submenu's is not a problem for me because they have a ResourceID, but the menu's that i want to change on runtime does not have that, or i can't find them? Thanks for helping me.

      R Offline
      R Offline
      RobJones
      wrote on last edited by
      #2

      I haven't tried this but it should work.. where 0 is the first item on the menu like "File". CMenu *pMenu = GetMenu(); CString csMnuStr; pMenu->GetMenuString(0, csMnuStr, MF_BYPOSITION); pMenu->ModifyMenu(0, MF_BYPOSITION, 0, "New Text"); DrawMenuBar(); Rob Whoever said nothing's impossible never tried slamming a revolving door!

      W 3 Replies Last reply
      0
      • W whofmans

        Hello! How can i change a menu name on runtime. With the menu-name i mean by example "File", "Edit" or "Help". Submenu's is not a problem for me because they have a ResourceID, but the menu's that i want to change on runtime does not have that, or i can't find them? Thanks for helping me.

        R Offline
        R Offline
        Renjith Ramachandran
        wrote on last edited by
        #3

        try DrawMenuBar() CodeTheDreams();

        1 Reply Last reply
        0
        • R RobJones

          I haven't tried this but it should work.. where 0 is the first item on the menu like "File". CMenu *pMenu = GetMenu(); CString csMnuStr; pMenu->GetMenuString(0, csMnuStr, MF_BYPOSITION); pMenu->ModifyMenu(0, MF_BYPOSITION, 0, "New Text"); DrawMenuBar(); Rob Whoever said nothing's impossible never tried slamming a revolving door!

          W Offline
          W Offline
          whofmans
          wrote on last edited by
          #4

          Thanks! Now automaticly all the menu-item texts goes through a translate function. So that my program works with different language's. // TRANSLATE THE MENUS! CMenu *pMenu = GetMenu(); CMenu *pSubMenu; CMenu *pSubSubMenu; CString csMnuStr; for(int i=0; pMenu->GetMenuState(i, MF_BYPOSITION) != -1; i++) // MENU { if(pMenu->GetMenuString(i, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pMenu->ModifyMenu(i, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); pSubMenu = pMenu->GetSubMenu(i); // Get menu items if(pSubMenu == NULL) // Submenu does not exist continue; for(int j=0; pSubMenu->GetMenuState(j, MF_BYPOSITION) != -1; j++) // SUBMENU { if(pSubMenu->GetMenuString(j, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pSubMenu->ModifyMenu(j, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); pSubSubMenu = pSubMenu->GetSubMenu(j); // get sub menu items if(pSubSubMenu == NULL) // SubSubMenu does not exist continue; for(int k=0; pSubSubMenu->GetMenuState(k, MF_BYPOSITION) != -1; k++) // SUB-SUBMENU { if(pSubSubMenu->GetMenuString(k, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pSubSubMenu->ModifyMenu(k, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); } } } DrawMenuBar();

          1 Reply Last reply
          0
          • R RobJones

            I haven't tried this but it should work.. where 0 is the first item on the menu like "File". CMenu *pMenu = GetMenu(); CString csMnuStr; pMenu->GetMenuString(0, csMnuStr, MF_BYPOSITION); pMenu->ModifyMenu(0, MF_BYPOSITION, 0, "New Text"); DrawMenuBar(); Rob Whoever said nothing's impossible never tried slamming a revolving door!

            W Offline
            W Offline
            whofmans
            wrote on last edited by
            #5

            Thanks! Now automaticly all the menu-item texts goes through a translate function. So that my program works with different language's. // TRANSLATE THE MENUS! CMenu *pMenu = GetMenu(); CMenu *pSubMenu; CMenu *pSubSubMenu; CString csMnuStr; for(int i=0; pMenu->GetMenuState(i, MF_BYPOSITION) != -1; i++) // MENU { if(pMenu->GetMenuString(i, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pMenu->ModifyMenu(i, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); pSubMenu = pMenu->GetSubMenu(i); // Get menu items if(pSubMenu == NULL) // Submenu does not exist continue; for(int j=0; pSubMenu->GetMenuState(j, MF_BYPOSITION) != -1; j++) // SUBMENU { if(pSubMenu->GetMenuString(j, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pSubMenu->ModifyMenu(j, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); pSubSubMenu = pSubMenu->GetSubMenu(j); // get sub menu items if(pSubSubMenu == NULL) // SubSubMenu does not exist continue; for(int k=0; pSubSubMenu->GetMenuState(k, MF_BYPOSITION) != -1; k++) // SUB-SUBMENU { if(pSubSubMenu->GetMenuString(k, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pSubSubMenu->ModifyMenu(k, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); } } } DrawMenuBar();

            1 Reply Last reply
            0
            • R RobJones

              I haven't tried this but it should work.. where 0 is the first item on the menu like "File". CMenu *pMenu = GetMenu(); CString csMnuStr; pMenu->GetMenuString(0, csMnuStr, MF_BYPOSITION); pMenu->ModifyMenu(0, MF_BYPOSITION, 0, "New Text"); DrawMenuBar(); Rob Whoever said nothing's impossible never tried slamming a revolving door!

              W Offline
              W Offline
              whofmans
              wrote on last edited by
              #6

              Thanks! Now automaticly all the menu-item texts goes through a translate function. So that my program works with different language's. // TRANSLATE THE MENUS! CMenu *pMenu = GetMenu(); CMenu *pSubMenu; CMenu *pSubSubMenu; CString csMnuStr; for(int i=0; pMenu->GetMenuState(i, MF_BYPOSITION) != -1; i++) // MENU { if(pMenu->GetMenuString(i, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pMenu->ModifyMenu(i, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); pSubMenu = pMenu->GetSubMenu(i); // Get menu items if(pSubMenu == NULL) // Submenu does not exist continue; for(int j=0; pSubMenu->GetMenuState(j, MF_BYPOSITION) != -1; j++) // SUBMENU { if(pSubMenu->GetMenuString(j, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pSubMenu->ModifyMenu(j, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); pSubSubMenu = pSubMenu->GetSubMenu(j); // get sub menu items if(pSubSubMenu == NULL) // SubSubMenu does not exist continue; for(int k=0; pSubSubMenu->GetMenuState(k, MF_BYPOSITION) != -1; k++) // SUB-SUBMENU { if(pSubSubMenu->GetMenuString(k, csMnuStr, MF_BYPOSITION) < 1) // empty string continue; pSubSubMenu->ModifyMenu(k, MF_BYPOSITION, 0, theApp.translate(csMnuStr)); } } } DrawMenuBar(); Willem

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups