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
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. How to change Menu caption dynamically?

How to change Menu caption dynamically?

Scheduled Pinned Locked Moved C / C++ / MFC
questiontutorial
6 Posts 3 Posters 3 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.
  • U Offline
    U Offline
    uus99
    wrote on last edited by
    #1

    I have a menu "Options" with one submenu "Start" Options>Start How can i change the caption of "Start" to "Stop" when i click the menu?

    B 1 Reply Last reply
    0
    • U uus99

      I have a menu "Options" with one submenu "Start" Options>Start How can i change the caption of "Start" to "Stop" when i click the menu?

      B Offline
      B Offline
      bneacetp
      wrote on last edited by
      #2

      Handle the ON_UPDATE_COMMAND_UI event for your "Start"/"Stop" menu item and then in that handler function something along the lines of...

      if(bStartMode)
      pCmdUI->SetText("Start");
      else
      pCmdUI->SetText("Stop");

      You could have code in the ON_COMMAND event handler to toggle the mode from start to stop. Hope this helps. :-D Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp

      U 1 Reply Last reply
      0
      • B bneacetp

        Handle the ON_UPDATE_COMMAND_UI event for your "Start"/"Stop" menu item and then in that handler function something along the lines of...

        if(bStartMode)
        pCmdUI->SetText("Start");
        else
        pCmdUI->SetText("Stop");

        You could have code in the ON_COMMAND event handler to toggle the mode from start to stop. Hope this helps. :-D Happy Programming and God Bless! "Your coding practices might be buggy, but your code is always right." Internet::WWW::CodeProject::bneacetp

        U Offline
        U Offline
        uus99
        wrote on last edited by
        #3

        I tried that, but i doesnt work. I'm using VC++6 with SP5 and my program is a dialog based program. void CTestUImageDlg::OnUpdateFileExit(CCmdUI* pCmdUI) { pCmdUI->SetText("Start"); } Nothing happens! Why??!!

        A 1 Reply Last reply
        0
        • U uus99

          I tried that, but i doesnt work. I'm using VC++6 with SP5 and my program is a dialog based program. void CTestUImageDlg::OnUpdateFileExit(CCmdUI* pCmdUI) { pCmdUI->SetText("Start"); } Nothing happens! Why??!!

          A Offline
          A Offline
          Antony M Kancidrowski
          wrote on last edited by
          #4

          Why have you put the code in the update handler for FileExit? You need to put it into the update handler for the menu item Start in the options menu. Ant. I'm hard, yet soft.
          I'm coloured, yet clear.
          I'm fuity and sweet.
          I'm jelly, what am I? Muse on it further, I shall return!
          - David Williams (Little Britain)

          U 1 Reply Last reply
          0
          • A Antony M Kancidrowski

            Why have you put the code in the update handler for FileExit? You need to put it into the update handler for the menu item Start in the options menu. Ant. I'm hard, yet soft.
            I'm coloured, yet clear.
            I'm fuity and sweet.
            I'm jelly, what am I? Muse on it further, I shall return!
            - David Williams (Little Britain)

            U Offline
            U Offline
            uus99
            wrote on last edited by
            #5

            I know that, i was testing if my Exit menu item will change it's caption. It was a test app, which does nothing. Just a menu with File>Exit. Clicking the Exit does not execute any function. So i just wanted to test if the caption changes, but it doesnt! Why?

            U 1 Reply Last reply
            0
            • U uus99

              I know that, i was testing if my Exit menu item will change it's caption. It was a test app, which does nothing. Just a menu with File>Exit. Clicking the Exit does not execute any function. So i just wanted to test if the caption changes, but it doesnt! Why?

              U Offline
              U Offline
              uus99
              wrote on last edited by
              #6

              I tried the samething with SDI app. And it works. But it doesnt in my dialog based app. Anyone?

              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