Solved

display chinese caption on cbutton

Posted on 2004-03-25
7
503 Views
Last Modified: 2011-10-03
Dear all,

    My computer system locale is Western English, and I want to display Chinese caption on the CButton as follows, however, it didn't work, do you know what's the problem?( I defined _UNICODE & UNICODE inside my project, and my resource file are already in CHINESE (PRC) format)


LPTSTR s_strRemarks=(LPTSTR)malloc((255)*sizeof(TCHAR));
s_strRemarks[0]=0x5c0f;  //Chinese character 1
s_strRemarks[1]=0x8003; //Chinese character 2
s_strRemarks[2]=0x8a66; //Chinese character 3
s_strRemarks[3]=0;

AfxMessageBox(s_strRemarks); //can display chinese character here inside the messagebox

///////////////Extra code for font///////////////
CFont m_font;
LOGFONT lf;
memset(&lf, 0, sizeof(LOGFONT));
lf.lfHeight = 10;    
lf.lfCharSet = CHINESEBIG5_CHARSET;
_tcscpy(lf.lfFaceName, _T("PMingLiU")); //chinese font
m_font.CreateFontIndirect(&lf);  
m_TestButton.SetFont(&m_font);
////////////

m_TestButton.SetWindowText(s_strRemarks);   //display garbage here no matter I have the "Extra code for font" or not.

delete[] s_strRemarks;
0
Comment
Question by:hpchong7
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
7 Comments
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10676289
Don't mix malloc and delete!!!! This will cause trouble eventually. Use free if you used malloc, and use delete if you used new.
0
 
LVL 44

Accepted Solution

by:
Karl Heinz Kremer earned 90 total points
ID: 10676314
You don't need the font code you've listed. The solution is much simpler than that: Just open the RC file of your project in a text editor (or open it as text in Visual Studio) and replace any occurance of "MS Sans Serif" with "MS Shell Dlg 2". Unfortunately this is not possble in the resource editor. This font is not displayed in the list of available fonts (it's not a real font, Windows replaced this virtual font with something that can display all your characters), so you have to do it in the RC file.
0
 
LVL 23

Expert Comment

by:chensu
ID: 10679638
What is your OS? Are those Chinese characters in Unicode?
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 2

Author Comment

by:hpchong7
ID: 10683767
Khkremer, your solution is great!However, I have further problems:

1.) MS shell Dlg 2 is only available after win2k. If my application need to run from win98 to winxp, what should I use? (add 20 pts more for solving this question)
2.)I've to apply activeskin on my project, after I applied it, the Chinese characters become ??? again, so how should I solve it? (add 50 pts more for solving this question)

Thanks!
0
 
LVL 44

Expert Comment

by:Karl Heinz Kremer
ID: 10683808
On an English system MS Shell Dlg 2 is very likely mapped to Tahoma, so you could try to use Tahoma instead of MS Shell Dlg 2. This may work on Win98 as well.

I don't know activeskin, so I have no idea what it does to the font selection. Sorry.
0
 
LVL 2

Author Comment

by:hpchong7
ID: 10684182
thanks!
0
 

Expert Comment

by:CeciliaS
ID: 10886908
Try this:
if Win32Platform = VER_PLATFORM_WIN32_NT ->'MS Shell Dlg 2'
otherwise -> 'MS Shell Dlg 2'.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Grammars for C C++ and java 1 145
Unresolved External Symbols 3 158
Least Squares Curve Fitting 4 133
I could not set window to top 4 63
In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question