Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to display extended ascii chars in dialog?

Status
Not open for further replies.

xyler

Programmer
Mar 5, 2002
2
IE
I want to display extended ascii characters (ohm symbol in particular) throughout my dialog box and app. MSDN says to use octal or hex notation of the ASCII character code. So, I tried...

AfxMessageBox("ohm hex: \xEA , ohm octal: \352");

But, this seems to display characters from the ANSI table.
ie. Displays char code 156 from ANSI. 156dec = 352oct.

Can someone tell me how I would display the Ohm symbol??
 
Hi,
You could create a font with CreateFont, using the GREEK_CHARSET, and then use SetFont. For example, to display the ohm symbol in an edit control in a dialog:

m_pFont = new CFont;
m_pFont->CreateFont(15, 7, 0, 0, 400, FALSE, FALSE, 0,
GREEK_CHARSET, OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
VARIABLE_PITCH | FF_MODERN, "Arial");
CEdit* pEdit = (CEdit*) GetDlgItem(IDC_EDIT1);
char str[2];
str[0] = '\xBF'; //The code in the Greek char set for Ohm
str[1] = 0;
pEdit->SetFont(m_pFont);
pEdit->SetWindowText(str);
(the m_pFont ptr is deleted later)

Hope this helps [ponder]
 
With the example above, I still get chars from the ANSI table. But, it seems to work with some changes - using SYMBOL_CHARSET and "Symbol" font. Looking up Symbol font in Charmap, the ohm symbol is '\x57'.


m_pFont->CreateFont(15, 7, 0, 0, 400, FALSE, FALSE, 0,
SYMBOL_CHARSET,
OUT_DEFAULT_PRECIS,
CLIP_DEFAULT_PRECIS, DEFAULT_QUALITY,
VARIABLE_PITCH | FF_MODERN, "Symbol");


Thanks for that!

 
Hi everyone,
The application I'm working on displays charts using the MSChart ActiveX.
Do you know of a way I could let the user print a chart to the printer?
(I know how to draw to the printer, I just don't know how to get the MSChart to draw itself there, rather then on screen.)

Thanks everyone
Gelbart
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top