MFC resource.h command/message IDs

前端 未结 3 1962
孤独总比滥情好
孤独总比滥情好 2021-01-13 09:05

I\'m working on an MFC application, that got pretty messy over years and over different teams of developers. The resource.h file, which contains all command/message mappings

相关标签:
3条回答
  • 2021-01-13 09:45

    You are mixing two things:

    1. Message IDs. These must be larger than WM_USER. Message IDs are not defined in resource.h. It seems from your description that you are not using application private messages.
    2. Command IDs. Your application itself must not have duplicate command IDs. The command ID values should also not interfere with the standard MFC IDs defined in afxres.h. Theses command IDs start at 0xE100, so it is unlikely that the values in resource.h. The resource compiler will generate an error for duplicate IDs in you rc file

    There is probably no need for you to edit resource.h manually.

    I would recommend to use the "Resource symbols" tool (right click on the resources in resource view and choose from the popup menu, I assume you are using VC++), to remove all the unused IDs from resource.h.

    0 讨论(0)
  • 2021-01-13 09:45

    Generally, there is no need to insert or edit the identifiers in resources manually (identifiers assingned by VS automatically in a correct manner). There are some cases that require manual interference in identifiers, but you can start with assumption, that work of previous teams of developers with resources was right. So if you did not encountered a problem because of resources, keep them untouched (IMHO).

    "MSDN docs mention that Command IDs and Message IDs should not be less than WM_USER and WM_APP correspondingly." - It seems you something mixed up.

    0 讨论(0)
  • 2021-01-13 09:56

    command messages are sent in WM_COMMAND with command id in parameter so it won't conflict other messages.

    0 讨论(0)
提交回复
热议问题