.NET Forum / Languages / Managed C++ / October 2005
Kanji character display in 7.1 MFC application vs. 6.0 MFC
|
|
Thread rating:  |
tomrmgc - 22 Oct 2005 00:36 GMT Here is the problem we've encountered. An application that used to successfully display Japanese Kanji characters no longer does so when recompiled with 7.1
When compiled with the 6.0 compiler, both of the following methods are successful in displaying Japanese characters in a multi-line CEdit control on a machine that is fully configured as a Japanese machine (Japanese version of Windows 2000 SP4). The same code, compiled with 7.1, only displays blanks or incorrect characters. The program is compiled for MBCS, not Unicode, so we are in effect calling SetWindowTextA in Method 1.
METHOD 1: ========= // Make a little buffer for the MBCS character
TCHAR cPtr[6]; for (int i = 0; i < 6; i++) cPtr[i] = 0; int iRet = WideCharToMultiByte (932, 0, L"\x3042", 1, cPtr, 6, NULL, NULL); // Display Hiragana A character m_cProblemEdit.SetWindowText(cPtr);
METHOD 2: =========
CString sProblem; //...Iinitialize sProblem with Kanji string .... // Display string m_CProblemEditSetWindow(sProblem);
"Gary Chang[MSFT]" - 22 Oct 2005 07:39 GMT Hi,
>Here is the problem we've encountered. An application >that used to successfully display Japanese Kanji characters >no longer does so when recompiled with 7.1 For a VC7.1 project, you need to specify its "Culture" to Japanese, this will make your programdisplay the Japanese Kanji characters as expected.
You can configure it in the Project property configuration(Project Property Pages/Resources/General/Culture).
Thanks!
Best regards,
Gary Chang Microsoft Community Support -------------------- Get Secure! ¡§C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp &SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Michael Viking - 22 Oct 2005 19:36 GMT > Hi, > [quoted text clipped - 4 lines] > For a VC7.1 project, you need to specify its "Culture" to Japanese, this > will make your programdisplay the Japanese Kanji characters as expected. I'm a little baffled by this, but maybe I don't understand it. What if the application is supposed to work with many "cultures" and not just the Japanese culture? As long as one doesn't switch their default (for non-unicode apps) code page, our app will support any double-byte language. Sounds like if we compiled with VC7.1 it no longer would. Am I missing something?
-Michael Viking
"Gary Chang[MSFT]" - 25 Oct 2005 08:10 GMT Hi Michael,
>I'm a little baffled by this, but maybe I don't understand it. >What if the application is supposed to work with many >"cultures" and not just the Japanese culture? For a general .NET WinForm application, you can set the target Form's "Localizable" property to true, then specify the language you need to support in its "Language" property, the VS2003 IDE will generate the multiple language support resource file respectively.
But in your case, to specify the project's "Culture" property is in order to tell the VS2003 IDE based on which language locale to compile your MFC project's resource, it is different with the general .NET application.
Thanks for your understanding!
Best regards,
Gary Chang Microsoft Community Support -------------------- Get Secure! ¡§C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp &SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Michael Viking - 25 Oct 2005 19:45 GMT Gary, I don't think I actually did understand you. Sorry. Please see inline:
> Hi Michael, > [quoted text clipped - 6 lines] > support in its "Language" property, the VS2003 IDE will generate the > multiple language support resource file respectively. So what would I select if I wanted to support Japanese, Chinese and Korean?
> But in your case, to specify the project's "Culture" property is in order > to tell the VS2003 IDE based on which language locale to compile your MFC > project's resource, it is different with the general .NET application. So I'd need to build my app three times with a different setting each time to support Korean, Chinese and Japanese?
> Thanks for your understanding! I'm doing my best.
Thanks, -Michael
"Gary Chang[MSFT]" - 26 Oct 2005 10:35 GMT Hi Michael,
>So what would I select if I wanted to support Japanese, >Chinese and Korean? In a .NET WinForm application, you may set the target Form's "Localizable" property to "True", then select the languages you want to support in the above "Language" property's drop-down listbox one by one, each time you select a language in that listbox, the VS2003 IDE will generate the corresponding language support resource file for the project.
>So I'd need to build my app three times with a different >setting each time to support Korean, Chinese and Japanese? It depends on do you need to produce the specific language version application, if yes, you may need to build your project 3 times with the different culture setting respectively. If not, I suggest you can use the general convention in such scenario, create the resource only DLLs for your application to support the multiple languages, please refer to the following MSDN KB and sample links for details:
http://support.microsoft.com/default.aspx?scid=kb;EN-US;198846 How To Create Localized Resource DLLs for MFC Application
Multiple language support for MFC applications with extension DLL http://www.codeproject.com/cpp/MultiLangSupportMFCExtDLL.asp
Wish this help!
Best regards,
Gary Chang Microsoft Community Support -------------------- Get Secure! ¡§C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp &SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Michael Viking - 27 Oct 2005 23:23 GMT Gary, thanks! All clear now. -Michael Viking
"Gary Chang[MSFT]" - 28 Oct 2005 03:55 GMT You are welcome, Michael:)
Good luck!
Best regards,
Gary Chang Microsoft Community Support -------------------- Get Secure! ¡§C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp &SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
tomrmgc - 26 Oct 2005 20:13 GMT Hi Gary, Thanks for the reply. We are still not able to get Kanji characters to display, even when setting the culture to Japanese in the resource settings. The only way we have found that we can get anything to work is to create an explicit font using one of the various CreateFont routines and use SetFont on the control, for example: CClientDC dc(this); CFont font; VERIFY(font.CreatePointFont(120, _T("MS Mincho"), &dc)); m_cEdit.SetFont(&font); font.DeleteObject(); ...though it seems that the act of creating the font is the important thing. The parameters don't seem to make much difference, even the font typeface or height. Please note we are not storing these Kanji strings as resources. They are input by the user via a programmatic interface and then passed through the application for eventual display in various controls. The application is otherwise English. So we are not trying necessarily to retarget the application at any one language. We are simply trying to get the controls to properly display an MBCS character string, in this case Japanese. At any rate, we did not have to have this font code in our 6.0 version, but now we seem to need it in order to get this functionality to work with 7.1. Any additional ideas or comments on this? Thanks!
> Hi, > [quoted text clipped - 21 lines] > > This posting is provided "AS IS" with no warranties, and confers no rights. "Gary Chang[MSFT]" - 27 Oct 2005 10:47 GMT Hi,
I am glad to know you have already found the resolution to your problem, I tested with a simple MFC6 dialogbox program, setting the culture of its upgraded VC7 project worked for me, it appears we don't have a similar test case:(
Thanks for sharing this useful tips with us!
Best regards,
Gary Chang Microsoft Community Support -------------------- Get Secure! ¡§C www.microsoft.com/security Register to Access MSDN Managed Newsgroups! http://support.microsoft.com/default.aspx?scid=/servicedesks/msdn/nospam.asp &SD=msdn
This posting is provided "AS IS" with no warranties, and confers no rights.
Free MagazinesGet these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...
|
|
|