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
Solved

display chinese caption on cbutton

Posted on 2004-03-25
7
500 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
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.
The viewer will learn how to clear a vector as well as how to detect empty vectors in C++.

808 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