BUG: An unexpected resource language change occurs with non-English language operating systems when you use an MFC class library as a static link library in Visual C++ .NET (832187)



The information in this article applies to:

  • Microsoft Visual C++ .NET (2003)
  • Microsoft Visual C++ .NET (2002)

SYMPTOMS

When you use a Microsoft Foundation Classes (MFC) class library as an MFC static library instead of as an MFC shared-dynamic link library (DLL) in an MFC program, a problem occurs with an unexpected change in the resource language. This unexpected change in the resource language occurs on a computer that has a non-English language operating system, such as a Japanese language operating system or a Chinese language operating system. The resource language changes to English although the language of the operating system is not English.

CAUSE

When you use an MFC static library, Microsoft Visual C++ .NET interprets the resource language as English instead of the language of the operating system that may be the Japanese language or the Chinese language. The resource language is not localized when the MFC class library is used in the form of an MFC static library. This problem occurs because the directory paths in the application resource file (.rc) are missing. When you create an MFC application by using Visual C++ .NET, the directory path (l.xxx) to the afxres.rc file and to the afxprint.rc file are omitted from the resource file (.rc) file.

Note In this article, xxx is a placeholder for the language short name. If you use the Japanese language, the placeholder must contain jpn. If you use the German language, the placeholder must contain deu. If you use the Chinese language, the placeholder must contain chs.

WORKAROUND

To work around this problem, you must edit the resource file (.rc) manually. You must put the missing directory path (l.xxx) in the resource file. The directory path denotes the language of the resources that must be used in the path of the afxres.rc file and in the path of the afxprint.rc file. You must include the directory path in all the occurrences of the afxres.rc file and in all occurrences of the afxprint.rc file.

For example, if you use the Japanese language, follow these steps:
  1. Start Notepad or another text editor.
  2. Open the resource file (.rc) of the MFCProject project in the editor.
  3. Search for all the occurrences of the following string in the resource file:
    afxres.rc
    Replace this string with the following string:
    l.jpn\\afxres.rc
  4. Search for all the occurrences of the following string in the resource file:
    afxprint.rc
    Replace this string with the following string:
    l.jpn\\afxprint.rc
  5. Save the resource (.rc) file.
  6. Open the MFCProject project in Microsoft Visual Studio .NET.
  7. Press CTRL+SHIFT+B to build the solution.
Note For example, If you use the Chinese language, you must replace the afxres.rc string and the afxprint.rc string with the l.chs\\afxres.rc string and the l.chs\\afxprint.rc string, respectively. You replace these strings in the resource file. You must change the language short name in the same manner for other languages.

You must build the solution again for the changes in the resource file to be effective.

STATUS

Microsoft has confirmed that this is a bug in the Microsoft products that are listed at the beginning of this article.

MORE INFORMATION

Steps to reproduce the problem

  1. Start Visual Studio .NET 2002 or Visual Studio .NET 2003 on a computer that has a Japanese language operating system or a Chinese language operating system installed.
  2. On the File menu, point to New, and then click Project.
  3. Under Project Types, click Visual C++ Projects, and then click MFC Application under Templates.
  4. In the Name text box, type MFCProject.
  5. In the Location text box, type C:\Test, and then click OK.
  6. In the MFC Application Wizard - MFCProject dialog box, click Application Type.
  7. Under Application type, click Single document.
  8. Verify that theResource Language is not English, but is the language of the operating system that you are using.

    By default, the operating system language is selected as the Resource Language. In this case it is either Japanese or Chinese.
  9. Click Finish to close the MFC Application Wizard - MFCProject dialog box.
  10. Press CTRL+SHIFT+B to build the project.
  11. Press CTRL+F5 to run the program.

    Notice that the title of the application appears in the same language as the language of the operating system that you are using.
  12. Close the application window.
  13. In Solution Explorer, right-click the MFCProject node, and then click Properties.
  14. In the MFCProject Property Pages dialog box, expand the Configuration Properties folder, and then click General.
  15. Under the Use of MFC property, change Use MFC in a Shared DLL to Use MFC in a Static Library.

    Note By default, the MFC application uses the MFC class library in the form of a shared DLL.
  16. Click Apply, and then click OK.
  17. Press CTRL+SHIFT+B to build the project.
  18. Press CTRL+F5 to run the program.

    The title of the application window appears in the English language instead of the non-English language of operating system that you are using.

Modification Type:MinorLast Reviewed:1/5/2006
Keywords:kbResource kbDlg kbLocalization kbbug KB832187 kbAudDeveloper