This is confusing me! I am reading this technical note and it states:
Prefix Resource type Valid rangeIDR_ multiple 1 through 0x6FFFIDD_ dialog templates 1 through 0x6FFFIDC_,IDI_,IDB_ cursors, icons, bitmaps 1 through 0x6FFFIDS_, IDP_ general strings 1 through 0x7FFFID_ commands 0x8000 through 0xDFFFIDC_ controls 8 through 0xDFFF
Then it states:
Windows implementation limitations restrict true resource IDs to be less than or equal to 0x7FFF.
MFC's internal framework reserves these ranges:
0x7000 through 0x7FFF (see afxres.h)
0xE000 through 0xEFFF (see afxres.h)
16000 through 18000 (see afxribbonres.h)
These ranges may change in future MFC implementations.
Several Windows system commands use the range of 0xF000 through 0xFFFF.
Control IDs of 1 through 7 are reserved for standard controls such as
IDOKandIDCANCEL.The range of 0x8000 through 0xFFFF for strings is reserved for menu prompts for commands.
Now I am completely confused.
ID_ Commands.The above makes sense. But then we have:
Can somebody provide in decimal and in plain English the correct ranges for the various resources?
The reason I am asking is because when using ResOrg it states:

Yet, it is flagging commands as out of range:

Those values are within 0x8000 through 0xDFFF.
I used Excel with formula to filter the list as I understand the ranges and this is the results:

First of all: There is no required range for commands from 0x8000 and up.
This requirement was in some very early versions of the MFC, where the command routing checked this range to reduce "roundtrips" for normal command IDs of controls, that are usually below this range.
I just rechecked the oldest MFC code (VC6.0 I still have in a VM) and I couldn't find any limitation about this in the MFC code there too.
But this is my experience and as you see in your code. Commands with IDs below 0x8000 work... and read my notes below about the ribbon code extension.
Command IDs (menu, toolbar, ribbon) must be below 0xF000 because the command IDs for the system are greater equal 0xF000.
Even the combination of the menu IDs with the corresponding prompt for the command line or Tooltip isn't a problem. You can use any number in the range of 0x0001 up to 0xDFFF.
String IDs in the MFC extend up to 0xFEFF.
Some dialogs and cursors and bitmaps are in the range of 0x7800 to 0x7FFF with some real large gaps.
Reserved IDs from the MFC are a different thing. But you have the header files and you can look into it what is used or not. Looking into the current header files, the used command ranges starts at 0xE000 and goes up to 0xEFFF.
Also I can't see the reasons for a limitation of other ID ranges (icons etc.) I can't see them neither in the MFC code nor in the Win32 code. So the ranges here are just the ranges that are allowed for the Win32 environment.
Even loading of the resources require always a HINSTANCE value. It is tricky how it is evaluated in the MFC because they have extension DLLs, but it helps to get not into conflict to the stock IDs.
The ribbon stuff uses Ids from 0x3E80 to 0x4650 (in fact it stops at 0x4330). The funny thing in here is that the ribbon just uses command IDs in this range. (See ID_AFX_TOOL...), so they don't care about the command range (above 0x8000).
So the only thing I can say from the code base I have and from my experience: Don't get into conflicts with the existing IDs. But use them freely as you like.
So even renumbering the IDs like the resorg tools does, isn't really needed. Because we have attached Help generation that sometimes get confused even if we use the generated help header files when we renumber IDs completely we reduce changes to the ID range to a cosmetic minimum.
So you may just ignore the warning of the old RESORG tool.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With