CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 1 of 2 12 LastLast
Results 1 to 15 of 22
  1. #1
    Join Date
    Feb 2005
    Posts
    25

    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.

  2. #2
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    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 ?

  3. #3
    Join Date
    Apr 2000
    Location
    Boston
    Posts
    124

    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.

  4. #4
    Join Date
    Feb 2005
    Posts
    25

    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.
    Attached Files Attached Files
    Last edited by Crenshaw; February 24th, 2005 at 05:07 PM.

  5. #5
    Join Date
    Feb 2000
    Location
    San Diego, CA
    Posts
    10,354

    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 ?

  6. #6
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688

    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?

  7. #7
    Join Date
    Feb 2005
    Posts
    25

    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.
    Last edited by Crenshaw; February 24th, 2005 at 04:59 PM.

  8. #8
    Join Date
    Feb 2005
    Posts
    25

    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?

  9. #9
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688

    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.

  10. #10
    Join Date
    Feb 2005
    Posts
    25

    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.

  11. #11
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688

    Re: Controls don't display Unicode Text

    I'm getting 8 compiler errors and I have problems with some libraries.

  12. #12
    Join Date
    Feb 2005
    Posts
    25

    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.

  13. #13
    Join Date
    Feb 2005
    Posts
    25

    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.

  14. #14
    Join Date
    Sep 2002
    Location
    Maryland - Fear The Turtle!
    Posts
    7,537

    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
    Last edited by Mick; February 24th, 2005 at 05:24 PM.

  15. #15
    Join Date
    Nov 2001
    Location
    Beyond Juslibol
    Posts
    1,688

    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.

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured