Microsoft KB Archive/51626
INF: STRINGTABLEs and Combined Resource Files
PSS ID Number: Q51626 Article last modified on 04-26-1993
2.03 2.10 3.00 WINDOWS
|The information in this article applies to:|
|- Microsoft Windows Software Development Kit for Windows version 3.0|
SYMPTOMS If you are developing a modular Windows application that includes multiple resource files, and each of the RC files contains several STRINGTABLE statements making your application quite large you may find that several of your “STRINGTALBE messages” are being omitted when you compile and run your application.
CAUSE The identifier values for STRINGTABLE resources must be chosen with care. Multiple RC files may contain many STRINGTABLE statements, but the different RC files may not share the same ranges of identifier values. This is due to the method Windows uses to store and reference STRINGTABLE resources. STRINGTABLE data is broken up into separate segments, each containing 16 strings. A modulo-16 algorithm is used to offset into a segment to select a specific string resource. The actual identifier values are used in constructing these segments. For example, consider the following RC file fragments: /* Table 1 / / Table 2 */ STRINGTABLE STRINGTABLE BEGIN BEGIN 1, “Hello” 3, “Error” 2, “GoodBye” 4, “Memory” END END If Tables 1 and 2 are in a single RC file, the resulting RES file will contain a single STRINGTABLE segment containing Strings 1 through 4. The problem with this setup occurs when Tables 1 and 2 are compiled separately and combined with the DOS COPY command. Each original RES file will contain its own STRINGTABLE segment, but produces an overlapping set of segments when combined during the binary copy process. A LoadString() will fail to access the correct string since it looks in the wrong place for the requested string.
RESOLUTION The solution is to use identifiers that do not share the same modulo-16 range over different RC files. To reflect this rule, the above example should look like the following: /* Table 1 / / Table 2 */ STRINGTABLE STRINGTABLE BEGIN BEGIN 1, “Hello” 17, “Error” 2, “GoodBye” 18, “Memory” END END In this form, Tables 1 and 2 could be compiled separately and produce a correctly formed RES with the DOS COPY command.
Addtional reference words: 3.0 KBCategory: KBSubcategory: UsrRscRareMisc Copyright Microsoft Corporation 1993.