Export (0) Print
Expand All

Compiling Resources

Compiling resource files using Visual C++ 2 requires clicking the Build button on the toolbar. As shown in Figure 4-2, located in the first section of this chapter, compiling resource files using the Win32 SDK requires three separate tools: the first tool you use is the RC compiler, which turns your .RC file into a .RES file; you then use the CVTRES tool to convert the .RES file into an object file; and finally, you link the object file to the program executable using LINK32.

In one special case, you must currently use the SDK tools: if you have resources in multiple languages that span more than one Windows code page. Suppose, for example, that you expand your English-language application to include Greek, Hungarian, and Russian user interface translations. The standard code page for English is 1252. The standard code page for Greek is 1253, the standard code page for Hungarian is 1250, and the standard code page for Russian is 1251. (See Appendix H.) Because the resource compiler can handle only one code page at a time, you need a separate .RC file for each of these languages. The translators need to see the localized text as it will appear in the final product, so your translators will edit the Greek file on a system that supports Greek characters, the Hungarian file on a system that supports Hungarian characters, and the Russian file on a system that supports Russian characters. (On Microsoft Windows 95, a single system can support all of these characters.) When you receive the translated files, you run the RC compiler on each file separately and link the results using CVTRES, as shown below.

RC /r /c1252 ENGLISH.RC
RC /r /c1253 GREEK.RC
RC /r /c1251 RUSSIAN.RC


You can install the code page information required by the /c flag by changing the language setting in Control Panel and supplying the requested floppy, CD-ROM, or network location. You need to install the information only once.

All Win32 resource strings are compiled into Unicode format, but the .RC file format is still expressed in the current default Windows character set*. You cannot edit a resource file containing English, Hungarian, and Russian text in Visual C++ 2 because Microsoft Windows NT 3.x supports only one default Windows code page at a time. Future versions of Visual C++ will probably take advantage of the multilingual features of Windows 95 (described in Chapter 6) or provide some other mechanism for supporting resource files in multiple character sets. The Win32 resource compiler can process files encoded in Unicode, but you would need to create such a file using a Unicode-enabled editor.

Porting existing resources to Win32 is straightforward. The Win32 resource compiler understands Windows 3.1 resource files, which is useful if you are porting your Windows 3.1 application to 32 bits. Also, Win32 console applications conveniently use Win32 resources, and you can share Win32 resources with Macintosh versions of your Windows-based applications by using the Visual C++ 2 Cross-Development Edition for the Macintosh. The Windows Portability Library resource compiler will automatically map strings contained in resource files from Windows character sets to the Macintosh character set, which is considerably different outside the ASCII range.

* RCDATA strings remain in ASCII unless they are L-quoted. Escape sequences are interpreted as Unicode when strings are L-quoted.

© 2014 Microsoft