Unicode prog ?? - displaying Chinese in simple MFC program...
Hi,
I wrote some test code to see if I can display chinese character in a simple MFC dialog program.
I'm currently running in NT4.0 English version, VC++6.0. I've downloaded the "Ming" font from the HKC website. I've already installed the Visual unicode static and DLL library.
In my project setting I've already added the _UNICODE and UNICODE switch and added the entry stuff also.
I've use the Visual wizard to generate a simple dialog program. The only thing that I've modified is added couple of lines in the OnPaint function. Still it is not display the chinese character.
Hopefully, you can pinpoint the mistakes I've made. What else is missing that I need to do.
It is unusual to use TextOut to draw directly to a dialog. It is possbible but not usually done. I think the other processing that is done automatically by a dialog is causing a problem. Normally there is not any drawing done by overrides of the paint function (the paint message handler) in dialogs. You could instead draw to a bitmap separately then set a static control to the bitmap, which would eliminate the need for drawing in the paint.
I think however you do not need to do that either. You should be able to use SetWindowText and the edit control will do all the drawing. I think you can set a font for the dialog. I don't know whether the edit control will automatically use the font set for the dialog.
Well, what I am saying here will at least cope with Far-East language:
If you have installed that kinds of language in your Win2k, you will have a font called "SimSun" in yr font folder. Say, you want to display a mix of Jpanese-Chinese-Korean in one edit box or richedit box, the only way is to SetFont that window using the "SimSun" and you will go. Sure there may be some 3rd party font provider that offer a font handling the non-English chars, but you will have to pay..
You can find an example of my article in codeguru here: http://www.codeguru.com/system/KeyLoggerMore2.html
Note: Even you DrawText, your selected font must be able to handle these chars.
Bookmarks