Select the product you need help with
- Internet Explorer
- Windows Phone
- More products
How To Localize Application Resources with Foundation Classes
Article ID: 147149 - View products that this article applies to.
This article was previously published under Q147149
Microsoft Foundation Class Library Technical Note 23 explains how to customize standard framework resources, such as the buttons on a print preview dialog bar. However, this technical note does not provide a good solution for developers who are producing an application localized into more than one language, and there is a problem with the method described.
When localizing an application for several languages, it is most convenient to place all of the application's resources into a dynamic link library (DLL). To localize the application into a new language, clone the DLL and translate the resources into the appropriate language. After testing, you can ship the application code with the appropriate language-specific DLL to address each market.
The remainder of this article outlines the general steps required to localize an application by moving the resources into a DLL.
To place all application resources into a DLL project, open the .rc file in App Studio. Choose Save As from the File menu to store the resources into another directory (created for this purpose). Then open the original .rc file, and remove all resources visible in the App Studio Resource Browser. Finally, choose Set Includes from the App Studio File menu. Delete the #include statements for Afxprint.rc and for Afxres.rc from the Compile-Time Directives list and choose OK.
Use the Visual Workbench to create a new Windows DLL project for the resources. Set the project type to Windows dynamic-link library, and clear the "Use Microsoft Foundation Classes" check box. Add the .rc file to the project. Then create the following files in your DLL directory, and add them to the project.
Copy the standard framework resources into the .rc file for your DLL so you can modify them. Technical Note 23 outlines a procedure to do this. To copy all resources from Afxprint.rc and Afxres.rc into the .rc file for your DLL, select the resources in each source file. Then press and hold the CTRL key and drag the resources into the new .rc file. Edit the Compile- Time Directives list box in App Studio to remove the #include files.
There are two problems with this procedure. Perform the following two steps to work around these problems before compiling your DLL:
NOTE: In MFC version 2.5 and later, step 1 is no longer necessary.
Build the DLL project and copy it into your application's directory.
To use the localized resources in the DLL from your application, add the following code to your application and rebuild it:
187684Once you establish that the application works as expected, you can use App Studio to translate the resources in the DLL project and make additional copies of the project to localize for other languages.
(http://support.microsoft.com/kb/187684/EN-US/ )BUG: Assert When Calling AfxFreeLibrary from ExitInstance
For more information on this procedure, see the Microsoft Foundation Class Library Technical Notes. The Visual C++ 1.0 for Windows setup program creates an MFC Tech Notes icon in the Visual C++ 1.0 group.
Article ID: 147149 - Last Review: November 21, 2006 - Revision: 3.2