Controls don't display Unicode Text
I'm trying to figure out this Unicode thing and it isn't working. I can get Unicode text to display in a CRichEdit control but nothing else. This is what I am using in other controls and it just gives me garbage:
Code:
m_cStatic.SetWindowText(m_sUnicodeText);
m_cLictBox.SetWindowText(m_sUnicodeText);
m_cGroupBox.SetWindowText(m_sUnicodeText);
m_cEdit.SetWindowText(m_sUnicodeText);
m_cComboBox.SetWindowText(m_sUnicodeText);
m_cCheckBox.SetWindowText(m_sUnicodeText);
m_cButton.SetWindowText(m_sUnicodeText);
I know that with a Rich Edit control I have to be using version 2.0 and I have to use some special messages to set the text. Is this the same way? If so what messages do I use?
P.S. Yes I have it set up with UNICODE and _UNICODE and I don't have _MBCS defined and I am using LPCTSTR and TCHAR and _T() etc.
Re: Controls don't display Unicode Text
You don't have to do anything special. If you are using _UNICODE , then your app will link to widechar version of Win32 APIs and that's all you need.
Can you zip the project and attach ?
Re: Controls don't display Unicode Text
If you have UNICODE defined, the code you have shown should work. The SetWindowText function differs when you have UNICODE defined:
Code:
BOOL WINAPI SetWindowTextA ( HWND hWnd, LPCSTR lpString );
BOOL WINAPI SetWindowTextW ( HWND hWnd, LPCWSTR lpString );
#ifdef UNICODE
#define SetWindowText SetWindowTextW
#else
#define SetWindowText SetWindowTextA
#endif
Maybe this article can help.
1 Attachment(s)
Re: Controls don't display Unicode Text
I figured that was the case. The trouble is it isn't working. It doesn't even work if I explicitly call the wide versions. Here is the whole project all zipped up. I'm (trying) to use Microsoft Layer For Unicode so the project is only likely to compile if you have updated your Platform SDK. The DLL for the layer in the sdk (unicows.dll) has to go in the same dirrectory as the EXE for the program to run. Thanx for helping.
Re: Controls don't display Unicode Text
Oops !! Where is the attachment ?
BTW, not sure if that attachment is gonna help. You are running 9x, right ?
Re: Controls don't display Unicode Text
Are you setting/do you have, an appropiate font in the controls? A font capable of displaying the unicode text you want to display?
Re: Controls don't display Unicode Text
Sorry I goofed, I'v added the attachment to the post above now. It didn't take the first time.
Re: Controls don't display Unicode Text
Quote:
Originally Posted by Doctor Luz
Are you setting/do you have, an appropiate font in the controls? A font capable of displaying the unicode text you want to display?
meaning??? I'm confused. Let me explain. This is the testing grounds. Once I know what I am doing I will need to be able to display unicode text from any language in nearly any control because I will be converting a rather large program to make it unicode compatable. Users will need to be able to support text from basicaly any language. How, if I need to, do I set up a font to do that?
Re: Controls don't display Unicode Text
you forgot to attach the "res" folder.
Well, it is difficult to have an universal unicode font. Perhaps Arial unicode is the more complete I know but I doubt it supports every language.
Re: Controls don't display Unicode Text
OK. I added the resources. Sorry. As far as the font goes, I'll try switching it to Arial and see what it does. Is there a special way to do this to make it support Unicode? I'll go for it and see what happens.
Re: Controls don't display Unicode Text
I'm getting 8 compiler errors and I have problems with some libraries.
Re: Controls don't display Unicode Text
Do you have the Updated Platform SDK? If not it's available at msdn.microsoft.com but it takes a while to download even with a realy fast connection.
Re: Controls don't display Unicode Text
I'm not %100 positive that I didn't have some open lines of code when I sent that off either. If the errors are on lines that are obviously incomplete just delete the lines.
Re: Controls don't display Unicode Text
Quote:
Originally Posted by Doctor Luz
I'm getting 8 compiler errors and I have problems with some libraries.
tsk tsk...Dr Luz that is not an adequte problem description :) What are the errors?
Complies fine for me VC6.0 + 2003 SDK
/after changing the lib path [killing the dependency path in the proj file] for the unicode library that is :)
Re: Controls don't display Unicode Text
Quote:
Originally Posted by Crenshaw
Do you have the Updated Platform SDK? If not it's available at msdn.microsoft.com but it takes a while to download even with a realy fast connection.
I suppose that is the problem. I recently had to reinstall VC and I don't have updated the platform SDK yet.
Re: Controls don't display Unicode Text
Quote:
Originally Posted by Mick
tsk tsk...Dr Luz that is not an adequte problem description :) What are the errors?
Complies fine for me VC6.0 + 2003 SDK
/after changing the lib path [killing the dependency path in the proj file] for the unicode library that is :)
You are right I should described better the problem. I've been bad.
And... since compiles fine for you... perhaps you can enlighten us... :D
Re: Controls don't display Unicode Text
Quote:
Originally Posted by Doctor Luz
You are right I should described better the problem. I've been bad.
And... since compiles fine for you... perhaps you can enlighten us... :D
Nah :) gonna help souldog out more up my alley than this GUI thingamabob...stuffins..
here is something for you though (these should fix your compiler errors) we can fire the lib to you if you need it.
Code:
#define ST_DEFAULT 0
typedef struct _settextex
{
DWORD flags; // Flags (see the ST_XXX defines)
UINT codepage; // Code page for translation (CP_ACP for sys default,
// 1200 for Unicode, -1 for control default)
} SETTEXTEX;
#define EM_SETTEXTEX (WM_USER + 97)
But if you really want me to look at this...well then twist my arm please :)
Re: Controls don't display Unicode Text
I can't make the font thing work. All it does is change the look of the letters but I still see the same charachters. Here is how I am creating and setting the font:
in the constructor for the dialog I do this:
fUnicodeFont.CreateFont(0, 0, 0, 0, 0, false, false, 0, DEFAULT_CHARSET, OUT_DEFAULT_PRECIS, CLIP_DEFAULT_PRECIS, PROOF_QUALITY, FF_DONTCARE, _T("Arial"));
and in OnInitDialog I do this:
m_cStatic.SetFont(&fUnicodeFont);
Am I doing something wrong or is this not the real problem?
Re: Controls don't display Unicode Text
There is no need to add "FFFE" to the begining of the text for the controls.
FFFE is a header for unicode text files in order to allow to the applications to recognise that the file is in unicode. But you don't need to put it in the text of a control.
Re: Controls don't display Unicode Text
Quote:
Originally Posted by Doctor Luz
There is no need to add "FFFE" to the begining of the text for the controls.
FFFE is a header for unicode text files in order to allow to the applications to recognise that the file is in unicode. But you don't need to put it in the text of a control.
I was grasping at straws.
Re: Controls don't display Unicode Text
And really it is not "Arial" it is "Arial unicode" they are different fonts, but I don't think you will need it unless you are trying to display japanese or something like that.
Can you show me how is the garbage you are obtaining, can you provide an example of which is the unicode text you want to display and what are the results?
Re: Controls don't display Unicode Text
I've attached a file that I saved out using some unicode charachters. If you open the file in the program it should display correctly in the rich edit view. If you hit the last button on the toolbar it will bring up a dialog with a bunch of controls on it. These controls have been loaded with garbage.