Re: How to write a program with multi-language support but not needed to define "UNICOE"?
- From: Goran <goran.pusic@xxxxxxxxx>
- Date: Tue, 22 Sep 2009 23:49:50 -0700 (PDT)
On Sep 23, 5:07 am, Black Smith wrote:
Hi,
I have do a little search and it ssems that if you want to write a multi-language support program but not want to define "UNICODE", you need:
1. Put each resource file with different langauge in different dll. But I haven't done this before. Is there any sample code teaches how to build resource file into a dll and how to use the dll type rescource file in program?
Even if you do use Unicode, that's still the method of choice. .NET
uses that; native Delphi (I know, irrelevant) uses that. MFC
applications should use that approach, too. About building resource-
only DLLs: see http://msdn.microsoft.com/en-us/library/24b2tcy0(VS.80).aspx..
About the sample code: for recent MFC versions, there should not be
any, InitInstance does it all, or almost^^^ (look appcore.cpp,
AfxLoadLangResourceDLL and friends).
So for example, you build your english resources into your *.exe, and
a resource-only DLL in German. You name that YourProgramDEU.dll (DEU
is LOCALE_SABBREVLANGNAME passed to GetLocaleInfo using locale ID
(LCID) of your user). You start your program under Windows in German
and MFC did it all for you.
^^^If you want your users to use Windows in one language, but only
your program in another, you have to store e.g. a desired LCID
somewhere and, upone startup of your program, use AfxLoadLibrary and
AfxSetResourceHandle manually. You should be able to find this
approach on CodeProject.
2. Use "SetThreadLocale()". But I don't the exactly usage of this API. Is there any sample about this API?
Ah, that's something else. Did you read the doc for that? It says
clearly "don't use it". That is useful if you put multiple same
resource in multiple languages in one *.rc, but that is AFAIK a
practice abandoned in favor of resource DLLs, so it's kinda
irrelevant.
3. Is there the third way to do multi-language support without define "UNICODE"?
You are mistaken. Multi-language support and Unicode, from the
standpoint of providing UI in multiple languages, are orthogonal
issues. Using Unicode is essential if you want your program to work
well WRT __user input__ in different languages. If your program is not
in Unicode, users can only enter text in language defined in Control
Panel->Regional and Language Options->Administrative->"Language for
non-Unicode programs" and English (and the fact that English works is
mostly by historical accident ;-) ).
Goran.
.
- References:
- Prev by Date: Re: Applying windows 7 theme in MFC application
- Next by Date: Re: CMutex /CEvent (multiple threads)
- Previous by thread: Re: How to write a program with multi-language support but not needed to define "UNICOE"?
- Next by thread: Re: How to write a program with multi-language support but not needed to define "UNICOE"?
- Index(es):
Relevant Pages
|
Loading