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