Localization of MFC-based components in VC 5.0

zhaozj2021-02-08  241

Sender: Cvisual (Beibei), Letter Area: Visualc

Title: Localization of MFC-based components in VC 5.0

Sending station: BBS Shuimu Tsinghua Station (Thu May 7 23:08:34 1998)

Visual C (hereinafter referred to as VC) is Microsoft's Visual Series Software Development Tools

one. For programmers in non-English areas, inevitably solve the localization of software

. The VC itself supports multilingual programming, which brings great convenience to localization. Here us

The localization of MFC-based components is mainly discussed.

To achieve the localization of components that use MFC, you need to solve the following two problems.

The localization of the component itself

The first question is, to realize localization of some special resources of the component itself, such as characters

Strings, dialogs, etc. Since most parts of the architecture on the MFC include and make

With a part of the resources defined by the MFC, these MFC resources must be localized.

. Fortunately, the MFC itself has provided a localized version of a variety of languages, including: Han

Language, German, Spanish, French, Italian, Japanese and Korean. Surrounded by VC

In the corresponding / devStudi / VC / MFC / [SRC | Include] /L.xxx/ directory in the disk, "L

"On behalf of" localization "," l.chs "represents Simplified Chinese. Add these directory *

.rc file is copied into the corresponding directory in the hard disk. When the application is stationary between the application and the MFC

This method should be used when the pattern is linked, but it is only in the professional version of VC 5.0 and the enterprise version.

Support for it.

Most applications use dynamic links between MFCs, at this time in Win95

In the System directory, there must be a local version of the corresponding MFC resource DLL file - MFC

4Xloc.dll (PWIN95 OemSR2 version is provided by MFC0 Loc.dll). VC disc

Documents in Directory / DevStudio / VC / Redist: MFC42XXX.DLL Copy to PWI95

In the system directory and renamed: mfc42loc.dll (where MFC42chs.dll is

Represents the resource DLL file of the Simplified Chinese version). In addition to solving the same name DLL before copying

In addition to the version of the cover, you should also pay attention to the following two aspects.

First, MFC4XLoc.D should not be installed on the English version of the system (such as English Win95)

LL. Because the English version of the resource file code is built in MFC4x.dll, the application is from M

The speed of the codes loaded in FC4x.dll ratio from the MFC4XLOCD LL first search again.

The speed of the code is much faster.

Second, because there are multiple versions of MFC4XLoc.dll, directory / devs in VC disc / DEVS

You can also find: mfc4xchs.dll in tudio / vc / redist - Simplified Chinese version

, MFC4XDEU.DLL - Germany version, MFC4xesp.ll - Italian version, etc.

So before installing, you should first determine the local version of the installed MFC4XLoc.dll.

The number is consistent with the WINDOW system used, for example: only MFC42chs.dll can

Install on the system of PWIN95.

It should be pointed out that the above method will bring a certain complex to the installation of the application.

Sex, because the user's system may have a variety of localized versions of applications. E.g:

Support Simplified Chinese; later installed a Japanese version of the software and linked library files MFC4XLOC.

There is only one DLL. If the latter covers the former, the application will have a resource link when the application is running.

Error. So we recommend using another way to build your local version of MFC

Resource DLL file instead of calling the MFC4XLoc.dll file directly, the method is later

Continue analysis.

Processing code

The second question is to handle the code of the localized resources of each component to make it good.

Run in the target environment. In most cases, this relies on the application of the application to bytes and

Double-byte character processing power. By default, MFC supports them.

Therefore, localized applications and DLLs essentially use local language to change the corresponding capital.

Source can be. If the C source code does not have a localized string or text, only

You need to modify the resource file. In fact, users can realize their own components, so there is no need to heavy

Enable the original code to get a local version. This may be complicated, but it is worth it, the MFC itself is also

This technology is used. Open the resource file editor to edit directly with local languages, but so that each version of the upgrade needs to be rebuilt.

Note: VC 4.0 or later version directly supports .rc files in multiple languages.

One way to avoid this is to establish an isolated DLL and conduct local

The DLL is sometimes called "satellite DLL". It will be dynamically

Link, at this time, the resource will be loaded from this "satellite DLL" instead of from the main model of the code.

Block load. MFC directly supports this method, MFC4XLoc.dll itself is a localization

"Satellite DLL", is only provided by the MFC under the default condition. We can

Create a "satellite DLL", if there is an app for MyApp.exe, it

All resources are all comes from a file called myres.dl. These are in their application

The order of InitInstance events are completed, as shown below:

CMYAPP :: InitInstance ()

{

// Initialization of the beginning of the code

Hinstance hinst = loadingLibrary ("myres.dll");

IF (hinst! = null)

AfxsetResourceHandle (Hinst);

/ / The following is other initialization code

.

.

.

}

After this code is executed, the MFC will load resources from MyRes.dll, not directly

Loaded from myApp.exe.

It is not difficult to build a single resource DLL file. Building a DLL project file first

And join .rc files and other necessary resources, then in the linker's parameters

Add a "/ noentry" parameter. This parameter tells the linker that the DLL is not connected

Inscription, because there is no code in the resource DLL file.

In addition, if the application is established in Win32 Release (ie in the EXE file)

Do not embed the debug code), then complete the following steps. In the project file, open the menu PR

Ojects / settings ..., selected C / C pages and r eSources page, will

Parameters [/ d "_afxdll"] Remove (which is typically generated by AppWizard). This parameter

Specifies to load resources only from the MFC's shared DLL file, and do not define other resources

Source, this user's own resource DLL file will not work.

Finally, because AppWizard is a major feature of VC , VC allows us to use AppWi

ZARD Create a MFC-based application framework, you can choose different languages, directly

Capable program framework. Among them, Korean and Simplified Chinese, due to the need to support double

The byte version of the operating system, so in the default, it corresponds to these three far East language.

The MFC AppWizard DLLS is not loaded with the VC 5.0 installer. Thus, in

In the first page of the application generated wizard, you can't find these language entries, but

It can be found in the / defstudio / sharedide / bi / IDE directory of the VC disc:

Language AppWizard DLL

-----------------------------------

Japanese ---- Appwzjpn.dll

Korean ---- Appwzkor.dll

Simplified Chinese ---- AppWZCHS.DLL

Under Simplified Chinese PWIN95, simply take the corresponding appwzchs.dll file from the VC CD

Copy into the / devsu dio / sharedide / bin / IDE directory of the hard drive. At this time, "

"This item will appear on the first page of the application generated wizard.

In the table box, as shown below:

figure 1

In this way, AppWizard generated application framework will automatically contain dishes in Simplified Chinese

Single, title, status bar, etc. We compile the framework to the link, and you will see one after running.

Beautiful full Chinese interface.

So, using VC to make simple Chinese software is very convenient, interested friends can continue

View the VC Help System to get more information. -

┌ ---- ┐

│Babe │

└ ---- ┘

※ Source: · BBS Shuimu Tsinghua Station bbs.net.tsinghua.edu.cn · [from: bbs.nju.edu.cn]

转载请注明原文地址:https://www.9cbs.com/read-1534.html

New Post(0)