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. custom menu item command ids

custom menu item command ids

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
3 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.
  • D Offline
    D Offline
    dene99970
    wrote on last edited by
    #1

    What is the exact acceptable range for creating your own custom command ids for menue items? I was trying to create a dynamic popup menu. Everything worked fine, I created menu item with AddMenu(): AddMenu(MF_ENABLED | MF_STRING, id, "aaa") my id was the problem. The numbers I was using were conflicting I guess with MFC reserved numbers. I experimented a bit and found that if I used really high numbers, starting at say 400000, it worked. Otherwise I get multiple errors, such as the right id not being returned in the OnCommand() override, or the menu item being greyed.

    M S 2 Replies Last reply
    0
    • D dene99970

      What is the exact acceptable range for creating your own custom command ids for menue items? I was trying to create a dynamic popup menu. Everything worked fine, I created menu item with AddMenu(): AddMenu(MF_ENABLED | MF_STRING, id, "aaa") my id was the problem. The numbers I was using were conflicting I guess with MFC reserved numbers. I experimented a bit and found that if I used really high numbers, starting at say 400000, it worked. Otherwise I get multiple errors, such as the right id not being returned in the OnCommand() override, or the menu item being greyed.

      M Offline
      M Offline
      Mark Salsbery
      wrote on last edited by
      #2

      This tech note may be slightly helpful... TN020: ID Naming and Numbering Conventions[^] This tech note should really be helpful TN035: Using Multiple Resource Files and Header Files with Visual C++[^] Particularly the parts pertaining to _APS_NEXT_RESOURCE_VALUE, _APS_NEXT_COMMAND_VALUE, etc. if you are sometimes assigning IDs yourself and sometimes letting the class wizard assign IDs.

      1 Reply Last reply
      0
      • D dene99970

        What is the exact acceptable range for creating your own custom command ids for menue items? I was trying to create a dynamic popup menu. Everything worked fine, I created menu item with AddMenu(): AddMenu(MF_ENABLED | MF_STRING, id, "aaa") my id was the problem. The numbers I was using were conflicting I guess with MFC reserved numbers. I experimented a bit and found that if I used really high numbers, starting at say 400000, it worked. Otherwise I get multiple errors, such as the right id not being returned in the OnCommand() override, or the menu item being greyed.

        S Offline
        S Offline
        Scott Holt
        wrote on last edited by
        #3

        Look up WM_USER in the help text. This is a #defined constant in the Windows header files that is always equal to the highest Windows message ID. Thus, you can safely define your own IDs starting at WM_USER + 1. Beware, however, that some Windows common controls use IDs above WM_USER, so what I have done use WM_USER + 1000, + 1001, + 1002, etc., and I have not had any problems. Scott

        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