KnowledgeBase Archive

An Archive of Early Microsoft KnowledgeBase Articles

View on GitHub

Q198536: HOWTO: #include the Localized MFC Resources in an EXE or DLL

Article: Q198536
Product(s): Microsoft C Compiler
Version(s): 4.0,4.1,4.2,5.0,6.0
Operating System(s): 
Keyword(s): kbIntl kbMFC kbResource kbVC400 kbVC500 kbVC600 kbLocalization kbDSupport kbIntlDev kbG
Last Modified: 10-JUN-2002

-------------------------------------------------------------------------------
The information in this article applies to:

- The Microsoft Foundation Classes (MFC), used with:
   - Microsoft Visual C++, 32-bit Editions, versions 4.0, 4.1 
   - Microsoft Visual C++, 32-bit Enterprise Edition, versions 4.2, 5.0, 6.0 
   - Microsoft Visual C++, 32-bit Professional Edition, versions 4.2, 5.0, 6.0 
   - Microsoft Visual C++, 32-bit Learning Edition, version 6.0 
-------------------------------------------------------------------------------

SUMMARY
=======

MFC provides resource files localized for certain locales, in the MFC\SRC\L.*
and MFC\Include\L.* directories. This article describes how to modify the
project settings and resource file to use these localized MFC resources.

NOTE: The information in this article does not apply to resources for ActiveX
controls.

MORE INFORMATION
================

Steps to include the localized resources:

1. On the Project menu, click Project Settings. In the Project Settings dialog
  box, select the Resource property page. Remove the _AFXDLL preprocessor
  definition. Click OK on the property sheet.

2. Open the string table using the Resource Editor and remove all the non
  application-specific strings generated by AppWizard. For example, if this
  application is an AppWizard-generated application, remove all the entries for
  the IDs from ID_FILE_NEW to the end of the string table. Strings for
  IDR_MAINFRAME, IDR_MYPROJTYPE, AFX_IDS_APP_TITLE, and AFX_IDS_IDLEMESSAGE are
  application-specific, and therefore localized strings are not provided by the
  MFC resource files.

3. On the View menu, click Resource Includes. In the Compile-time directives
  window, do the following:

  a. Set the primary language ID and the sub-language ID appropriately in the
     LANGUAGE statement. The appropriate values can be found in the
     ...\vc\include\winnt.h file. Note that the values specified in the
     LANGUAGE statement must be base-10. The values in Winnt.h are base-16.

Example: LANUGAGE 11, 1  // Specifies standard French

  b. Make sure that the code page specified in the #pragma code_page statement
     is correct. For ANSI English and most European languages the code page is
     1252; for Japanese it is 932.

  c. Modify the existing statements that include resources used by the MFC
     framework. These resources are located in the appropriate localized
     ..\vc\mfc\include directory. For example, change the following

           #include "afxres.rc"
           #include "afxprint.rc"
           #include "afxolecl.rc"
           #include "afxolesv.rc"

     to the following:

           #include "l.fra/afxres.rc"
           #include "l.fra/afxprint.rc"
           #include "l.fra/afxolecl.rc"
           #include "l.fra/afxolesv.rc"

     (A project will use the Afxolecl.rc and Afxolesv.rc files only if they are
     OLE client and/or server applications.)

  d. The Indicate.rc and Prompts.rc files contain the key-state indicators and
     menu-prompt strings that are displayed on the status bar by MFC. These
     files are located in the ..\vc\mfc\src directory. To include these files,
     #include them and explicitly specify their location. For example:

           #include "c:\VC\mfc\src\l.fra\prompts.rc"
           #include "c:\VC\mfc\src\l.fra\indicate.rc"

  e. Click OK to close the Resource Includes dialog box.

4. Build the application or DLL.

REFERENCES
==========

Technical Note 23 "Standard MFC Resources"

For additional information, please see the following article in the Microsoft
Knowledge Base:

Q200555 Localizing Stock ActiveX Property Pages With MFC Rescues


(c) Microsoft Corporation 1998, All Rights Reserved. Contributions by Isaac
Varon, Microsoft Corporation.


Additional query words:

======================================================================
Keywords          : kbIntl kbMFC kbResource kbVC400 kbVC500 kbVC600 kbLocalization kbDSupport kbIntlDev kbGrpDSMFCATL 
Technology        : kbAudDeveloper kbMFC
Version           : :4.0,4.1,4.2,5.0,6.0
Issue type        : kbhowto

=============================================================================

THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Copyright Microsoft Corporation 1986-2002.