在Win32 API应用程序中实现全球化/多语言功能 [英] Implementing Globalization / Multilingual feature in win32 API application

查看:247
本文介绍了在Win32 API应用程序中实现全球化/多语言功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经用Visual C ++开发了一个窗口应用程序(Win32 API).我必须在此应用程序中添加多语言功能.任何人都可以指导我如何完成这项任务.

I have developend a window application(Win32 API) in visual C++. I have to add multilingual feature in this application. Can any one Pls guide me how to get forward with this task.

推荐答案

Windows上多语言应用程序的基础是资源"的使用.资源是附加在可执行文件末尾的块,它仅包含数据,并且以非常特定的方式进行格式化,以便Windows能够解释这些数据.

the basics for a multilingual application on Windows is the use of "resources". a resource is a chunk appended at the end of your executable, which only contains data, and is formatted in a very specific way in order for Windows to be able to interpret those data.

在您的资源中,您可以找到对话框,字符串表以及版本信息(在资源管理器中文件的属性对话框中显示的版本信息).您可以通过在Visual C ++中打开exe或dll来监视任何dll或exe的资源.在开发应用程序时,您可以创建资源(文件/新建),将其添加到项目中(与添加文件时相同)并编辑资源(使用资源编辑器,通常是文件视图"旁边的选项卡)在项目资源管理器中).

in your resources, you can find dialog boxes, string tables, but also version informations (those which are displayed in the properties dialog box of a file in the explorer). you can watch the resources of any dll or exe by opening the exe or dll in Visual C++. when developing an application, you can create a resource (File/New), add it to your project (the same as you when you add a file) and edit the resources (using the resource editor, generally a tab next to the File View in project explorer).

每个资源(对话框,对话框,模板,版本信息,字符串表等)都包含可以更改的语言标识符.您可以使用不同的语言标识符多次创建相同的资源.编译后,当Windows加载应用程序时,它将尝试打开与Windows UI语言更接近的语言的资源.

each resource (dialog, dialog, template, version info, string table, ...) contains a language identifier which you can change. you can create the same resource multiple times using different language identifier. once compiled, when the application is loaded by Windows, it will try to open resources which language are the closer to the Windows UI language.

Windows SDK中定义了一组函数,以充分利用这些资源:LoadString,LoadCursor,LoadBitmap以及

a set of functions is defined in the Windows SDK to make good use of those resources: LoadString, LoadCursor, LoadBitmap, and everything in the resources chapter.

现在,每次在代码中使用字符串时,都将其放入String Table资源中,并使用LoadString函数进行检索.只要您在资源中设置了正确的语言标识符,通常就可以使用正确的语言加载窗口和对话框,而无需任何特定的函数调用.

Now every time you use a string in your code, put it in a String Table resource and use the LoadString function to retrieve it. windows and dialog boxes are generally loaded in the correct language without needing any specific function call, as long as you have set the correct language identifier in the resources.

瞧,这是我能做的关于Windows下多语言开发的最简短的介绍.我相信您可以在Windows网上找到很多有关资源或多语言开发的写得很好的文章.

voila, that's the shortest introduction to multilingual development under Windows that i could do. i am sure that you can find a lot of well-written articles about resources or multilingual development under Windows on the net.

这篇关于在Win32 API应用程序中实现全球化/多语言功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆