Solved

display chinese caption on cbutton

Posted on 2004-03-25
7
499 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
Are your AD admin tools letting you down?

Managing Active Directory can get complicated.  Often, the native tools for managing AD are just not up to the task.  The largest Active Directory installations in the world have relied on one tool to manage their day-to-day administration tasks: Hyena. Start your trial today.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

773 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