Share via


$$SET_DEFAULT_LANG

OverviewsHow Do IDetails

Feature Only in Professional and Enterprise Editions   Creating a Custom AppWizard is supported only in Visual C++ Professional and Enterprise Editions. For more information, see .

$$SET_DEFAULT_LANG( macro-name );

Parameters

macro-name

A macro name you add to the dictionary. The value of macro-name must be a three-letter string that corresponds to a language previously selected by an MFC AppWizard or custom AppWizard user. The following table provides a partial list of possible values for macro-name.

Language Identifiers

Value Language
DEU German
ENU English
ESP Spanish
FRA French
ITA Italian
JPN Japanese
SVE Swedish

Remarks

You use the $$SET_DEFAULT_LANG directive to specify a language-identifer for the CCustomAppWiz::LoadTemplate function to use when it searches for a custom resource template to load for use by CCustomAppWiz::CopyTemplate or CCustomAppWiz::ProcessTemplate.

Note   Code to perform the following procedure is automatically generated if your custom AppWizard uses the existing set of MFC AppWizard steps for generating an executable file and if you select more than one language from the Custom AppWizard project type’s language list.

If you use the $$SET_DEFAULT_LANG directive in a loop defined by the $$BEGINLOOP and $$ENDLOOP directives, you can use $$BEGINLOOP and $$ENDLOOP to modify macros to write code that finds, extracts, and processes multiple language versions of a language-specific template. For information on how $$BEGINLOOP and $$ENDLOOP modify macros, see $$BEGINLOOPand$$ENDLOOP.

The language identifier, which is the value of macro-name, also specifies the search order that LoadTemplate uses to search for a DLL.

Say that $$SET_DEFAULT_LANG is called with a macro-name that expands to “DEU”. LoadTemplate will go through the following algorithm to locate a template named TEMPLATE.RC:

  1. Try locating TEMPLATE_DEU.RC in the custom AppWizard’s resources.

  2. If not there, try locating TEMPLATE.RC in the custom AppWizard’s resources.

  3. If not there, try locating TEMPLATE.RC in MFCAPWZ.DLL

  4. If not there, try locating TEMPLATE.RC in APPWZDEU.DLL

  5. If not there, try locating TEMPLATE.RC in all the other APPWZ*.DLLs selected by the custom AppWizard user.

  6. If not there, display an error and stop file generation.

Notice that in step 1, LoadTemplate looks for the template under the localized name (TEMPLATE_DEU.RC). If it can’t find a template named TEMPLATE_DEU.RC in the custom AppWizard’s resources, it reverts back to searching for the actual name (TEMPLATE.RC).

Note   If AppWizard itself is being run rather than a custom AppWizard, MFCAPWZ.DLL starts the search process at step 3, and thus never tries to locate the template under the localized name.

Example

Imagine that a user of your custom AppWizard generates a project that will generate an application for use by English-, French-, and Japanese-speaking people. To create the user’s project, your custom AppWizard must find the templates containing strings translated into these languages. It must search in DLLs that include, at least, your custom AppWizard’s DLL, MFCAPWZ.DLL, and possibly APPWZENU.DLL, APPWZFRA.DLL, and APPWZJPN.DLL. For simplicity, we will examine finding and loading one template, FILE.TXT.

Because FILE.TXT is a text file, it will probably be translated into English, French, and Japanese. Your custom AppWizard’s DLL must contain three versions of this file named FILE_ENU.TXT, FILE_FRA.TXT, and FILE_JPN.TXT. Also, your custom AppWizard must make the following addition to the dictionary:

myprojectaw.m_Dictionary[“FILE”] = “FILE.TXT”;

To track the three languages specified by the user, you add macros to the dictionary as follows:

myprojectaw.m_Dictionary[“LANG_SUFFIX_0”] = “ENU”;
myprojectaw.m_Dictionary[“LANG_SUFFIX_1”] = “FRA”;
myprojectaw.m_Dictionary[“LANG_SUFFIX_2”] = “JPN”;

Then, when your custom AppWizard must find and load language-specific templates, it does so in a loop as follows:

$$BEGINLOOP(NUM_LANGS)
$$SET_DEFAULT_LANG(LANG_SUFFIX)
$$// Include text from the
$$// properly localized template:
$$INCLUDE(FILE)
$$ENDLOOP

If NUM_LANGS has the value of “3”, then this loop will iterate three times. During each iteration, MFCAPWZ.DLL will modify its lookup procedure for the LANG_SUFFIX macro and CCustomAppwiz::LoadTemplate will modify its template-loading procedure as follows:

  • First iteration: LANG_SUFFIX first becomes LANG_SUFFIX_0. The value of FILE is extracted from the dictionary and, when $$INCLUDE causes LoadTemplate to be called, the value of FILE is combined with the value of LANG_SUFFIX_0 to produce FILE_ENU.TXT.

  • Second iteration: LANG_SUFFIX first becomes LANG_SUFFIX_1. The value of FILE is extracted from the dictionary and, when $$INCLUDE causes LoadTemplate to be called, the value of FILE is combined with the value of LANG_SUFFIX_1 to produce FILE_FRA.TXT.

  • Third iteration: LANG_SUFFIX first becomes LANG_SUFFIX_2. The value of FILE is extracted from the dictionary and, when $$INCLUDE causes LoadTemplate to be called, the value of FILE is combined with the value of LANG_SUFFIX_2 to produce FILE_JPN.TXT.

Thus, the value of LANG_SUFFIX is transformed to “ENU”, “FRA”, and “JPN” and LoadTemplate will know to first load APWZENU.DLL, then APWZFRA.DLL, and finally APWZJPN.DLL if any of the templates it seeks are not in the custom AppWizard’s DLL. For more information on the transformation of macro names, see $$BEGINLOOPand$$ENDLOOP.

Note   The argument to the $$SET_DEFAULT_LANG directive must correspond to an APPWZ*.DLL already chosen by the MFC AppWizard or custom AppWizard user. Otherwise, MFCAPWZ.DLL will display an error message and stop file generation immediately after parsing the $$SET_DEFAULT_LANG directive.

See Also   AppWizard Language Support for Far East Languages, Standard AppWizard Directives, The Dictionary, CCustomAppwiz::LoadTemplate, CCustomAppwiz::ProcessTemplate, CCustomAppwiz::CopyTemplate, CCustomAppwiz::PostProcessTemplate, $$BEGINLOOP, $$ENDLOOP, Standard MFC AppWizard Directives, How Macros Get Their Values