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. CMenu -> GetMenuString -> Get text and shortcut key seperate

CMenu -> GetMenuString -> Get text and shortcut key seperate

Scheduled Pinned Locked Moved C / C++ / MFC
algorithmshelpquestion
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.
  • K Offline
    K Offline
    karhong
    wrote on last edited by
    #1

    Hi, I've created an owner draw Menu and i wanted to get the text and the shortcut key seperately. Any idea?? By calling below code, it will get both text and shortcut key and put inside a string. COwnerMenu OwnerMenu; //this is inherit from CMenu OwnerMenuPointer->GetMenuString(i, str, MF_BYPOSITION); I tried to seperate it by searching "Ctrl+" But as the shortcut key might not started with Ctrl+, so i cant use this method.. Can i get the shortcut key and also the text seperately by using the pointer "OwnerMenuPointer" ?? I've search through net and I cant find any solution Any help would be appreciated. Regards, KH

    good

    L I 2 Replies Last reply
    0
    • K karhong

      Hi, I've created an owner draw Menu and i wanted to get the text and the shortcut key seperately. Any idea?? By calling below code, it will get both text and shortcut key and put inside a string. COwnerMenu OwnerMenu; //this is inherit from CMenu OwnerMenuPointer->GetMenuString(i, str, MF_BYPOSITION); I tried to seperate it by searching "Ctrl+" But as the shortcut key might not started with Ctrl+, so i cant use this method.. Can i get the shortcut key and also the text seperately by using the pointer "OwnerMenuPointer" ?? I've search through net and I cant find any solution Any help would be appreciated. Regards, KH

      good

      L Offline
      L Offline
      L Madhavan
      wrote on last edited by
      #2

      The shortcut text is separated from the menu item text by a tab character. Just search for \t within the menu string and split it at that point.

      K 1 Reply Last reply
      0
      • L L Madhavan

        The shortcut text is separated from the menu item text by a tab character. Just search for \t within the menu string and split it at that point.

        K Offline
        K Offline
        karhong
        wrote on last edited by
        #3

        OH THANKS!!! IT WORKS !!

        good

        L 1 Reply Last reply
        0
        • K karhong

          OH THANKS!!! IT WORKS !!

          good

          L Offline
          L Offline
          L Madhavan
          wrote on last edited by
          #4

          How are you defining the menu items? Usually, you define a shortcut key for a menu item using \t and Windows displays the shortcut on the right hand side of the menu. For example, in the resource editor, you would define New as New\tCtrl+N

          1 Reply Last reply
          0
          • K karhong

            Hi, I've created an owner draw Menu and i wanted to get the text and the shortcut key seperately. Any idea?? By calling below code, it will get both text and shortcut key and put inside a string. COwnerMenu OwnerMenu; //this is inherit from CMenu OwnerMenuPointer->GetMenuString(i, str, MF_BYPOSITION); I tried to seperate it by searching "Ctrl+" But as the shortcut key might not started with Ctrl+, so i cant use this method.. Can i get the shortcut key and also the text seperately by using the pointer "OwnerMenuPointer" ?? I've search through net and I cant find any solution Any help would be appreciated. Regards, KH

            good

            I Offline
            I Offline
            Iain Clarke Warrior Programmer
            wrote on last edited by
            #5

            You should also look at this article: http://www.codeproject.com/KB/menus/newmenuxpstyle.aspx[^] I helped the author add code to parse the accelerotor table to get the short cut keys, cutting out the need to write them in the menu initially. This also lets you have changeable keys in your software. And it's a super article before I put my nose in... Iain.

            K 1 Reply Last reply
            0
            • I Iain Clarke Warrior Programmer

              You should also look at this article: http://www.codeproject.com/KB/menus/newmenuxpstyle.aspx[^] I helped the author add code to parse the accelerotor table to get the short cut keys, cutting out the need to write them in the menu initially. This also lets you have changeable keys in your software. And it's a super article before I put my nose in... Iain.

              K Offline
              K Offline
              karhong
              wrote on last edited by
              #6

              oh thanks !! Its a great article ^^

              good

              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