Solved

display chinese caption on cbutton

Posted on 2004-03-25
7
497 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
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
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
Container Orchestration platforms empower organizations to scale their apps at an exceptional rate. This is the reason numerous innovation-driven companies are moving apps to an appropriated datacenter wide platform that empowers them to scale at a …
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

760 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

Need Help in Real-Time?

Connect with top rated Experts

23 Experts available now in Live!

Get 1:1 Help Now