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. CMenus : How to use menu handles instead of menu resource ID when needed ?

CMenus : How to use menu handles instead of menu resource ID when needed ?

Scheduled Pinned Locked Moved C / C++ / MFC
questionjsontutoriallearning
10 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.
  • S Offline
    S Offline
    sdancer75
    wrote on last edited by
    #1

    Hi, I show that some CMenu methods, need the ID of the menu that is already created inside the resource manager. But, if the CMenu is created dynamically how do I assign a unique ID for that object ? If that is not possible, then how can I "translate" the menu handle to this unique resource ID so it would compatible with the Win32 API functions ? Regards,

    sdancer75

    L CPalliniC 2 Replies Last reply
    0
    • S sdancer75

      Hi, I show that some CMenu methods, need the ID of the menu that is already created inside the resource manager. But, if the CMenu is created dynamically how do I assign a unique ID for that object ? If that is not possible, then how can I "translate" the menu handle to this unique resource ID so it would compatible with the Win32 API functions ? Regards,

      sdancer75

      L Offline
      L Offline
      Lost User
      wrote on last edited by
      #2

      If it is a dynamically created menu then it cannot have a resource id, since there is no associated resource. It would probably help if you showed the piece of code that you are having a problem with.

      1 Reply Last reply
      0
      • S sdancer75

        Hi, I show that some CMenu methods, need the ID of the menu that is already created inside the resource manager. But, if the CMenu is created dynamically how do I assign a unique ID for that object ? If that is not possible, then how can I "translate" the menu handle to this unique resource ID so it would compatible with the Win32 API functions ? Regards,

        sdancer75

        CPalliniC Online
        CPalliniC Online
        CPallini
        wrote on last edited by
        #3

        You can definitely assign IDs to dynamically created menu items, see the CMenu::AppendMenu[^] method.

        THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

        In testa che avete, signor di Ceprano?

        S L 2 Replies Last reply
        0
        • CPalliniC CPallini

          You can definitely assign IDs to dynamically created menu items, see the CMenu::AppendMenu[^] method.

          THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

          S Offline
          S Offline
          sdancer75
          wrote on last edited by
          #4

          From MSDN AppendMenu function 7 out of 10 rated this helpful - Rate this topic Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item. That's correct, but if the menu is a brand new dynamically created popupmenu and I dont want to append it to an existing menu, there is no point to use AppendMenu, right ?

          sdancer75

          CPalliniC L 2 Replies Last reply
          0
          • S sdancer75

            From MSDN AppendMenu function 7 out of 10 rated this helpful - Rate this topic Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item. That's correct, but if the menu is a brand new dynamically created popupmenu and I dont want to append it to an existing menu, there is no point to use AppendMenu, right ?

            sdancer75

            CPalliniC Online
            CPalliniC Online
            CPallini
            wrote on last edited by
            #5

            Not right. When you dynamically create a menu, it has no items: you have to use the AppendMenu method to add, at least a menu item to it.

            THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

            In testa che avete, signor di Ceprano?

            1 Reply Last reply
            0
            • CPalliniC CPallini

              You can definitely assign IDs to dynamically created menu items, see the CMenu::AppendMenu[^] method.

              THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

              L Offline
              L Offline
              Lost User
              wrote on last edited by
              #6

              That's the id of the associated command, which is not the same as resource id. But maybe that is what the OP is really asking for.

              CPalliniC 1 Reply Last reply
              0
              • S sdancer75

                From MSDN AppendMenu function 7 out of 10 rated this helpful - Rate this topic Appends a new item to the end of the specified menu bar, drop-down menu, submenu, or shortcut menu. You can use this function to specify the content, appearance, and behavior of the menu item. That's correct, but if the menu is a brand new dynamically created popupmenu and I dont want to append it to an existing menu, there is no point to use AppendMenu, right ?

                sdancer75

                L Offline
                L Offline
                Lost User
                wrote on last edited by
                #7

                I suspect you are getting your terminology wrong, and as suggested please show the code that you are having problems with, and why you think it needs this id.

                S 1 Reply Last reply
                0
                • L Lost User

                  That's the id of the associated command, which is not the same as resource id. But maybe that is what the OP is really asking for.

                  CPalliniC Online
                  CPalliniC Online
                  CPallini
                  wrote on last edited by
                  #8

                  You are right, of course (on both the points, I hope).

                  THESE PEOPLE REALLY BOTHER ME!! How can they know what you should do without knowing what you want done?!?! -- C++ FQA Lite

                  In testa che avete, signor di Ceprano?

                  1 Reply Last reply
                  0
                  • L Lost User

                    I suspect you are getting your terminology wrong, and as suggested please show the code that you are having problems with, and why you think it needs this id.

                    S Offline
                    S Offline
                    sdancer75
                    wrote on last edited by
                    #9

                    Richard MacCutchan wrote:

                    I suspect you are getting your terminology wrong, and as suggested please show the code that you are having problems with, and why you think it needs this id.

                    Yes, there was a terminology wrong from my side..... The misunderstanding was done when I tried to initialize a CXTPBrowseButton from Codejock's framework and I needed a resource ID menu but I only create that menu dynamically. The code example I tried to customize is :

                    m_edit1.Initialize(this, BES_XTP_POPUPMENU, IDR_POPUP);

                    and is declared like

                    virtual bool Initialize(CWnd* pParentWnd, DWORD dwBStyle, UINT nMenu = 0, int nSubMenuIndx = 0);

                    It seems that I dont have an option in this situation to pass an object handle !!!! My worng thoughts was that I just needed an ID just to make an object unique for the internal use of the MFC framework but I didn't thought that it was merely a unique RESOURCE ID. Thanks for clarifying this..... I just dazed and confused.

                    sdancer75

                    L 1 Reply Last reply
                    0
                    • S sdancer75

                      Richard MacCutchan wrote:

                      I suspect you are getting your terminology wrong, and as suggested please show the code that you are having problems with, and why you think it needs this id.

                      Yes, there was a terminology wrong from my side..... The misunderstanding was done when I tried to initialize a CXTPBrowseButton from Codejock's framework and I needed a resource ID menu but I only create that menu dynamically. The code example I tried to customize is :

                      m_edit1.Initialize(this, BES_XTP_POPUPMENU, IDR_POPUP);

                      and is declared like

                      virtual bool Initialize(CWnd* pParentWnd, DWORD dwBStyle, UINT nMenu = 0, int nSubMenuIndx = 0);

                      It seems that I dont have an option in this situation to pass an object handle !!!! My worng thoughts was that I just needed an ID just to make an object unique for the internal use of the MFC framework but I didn't thought that it was merely a unique RESOURCE ID. Thanks for clarifying this..... I just dazed and confused.

                      sdancer75

                      L Offline
                      L Offline
                      Lost User
                      wrote on last edited by
                      #10

                      I have never come across Codejock so cannot offer any suggestions.

                      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