Articles   Members Online:
-Article/Tip Search
-News Group Search over 21 Million news group articles.
-Delphi/Pascal
-CBuilder/C++
-C#Builder/C#
-JBuilder/Java
-Kylix
Member Area
-Home
-Account Center
-Top 10 NEW!!
-Submit Article/Tip
-Forums Upgraded!!
-My Articles
-Edit Information
-Login/Logout
-Become a Member
-Why sign up!
-Newsletter
-Chat Online!
-Indexes NEW!!
Employment
-Build your resume
-Find a job
-Post a job
-Resume Search
Contacts
-Contacts
-Feedbacks
-Link to us
-Privacy/Disclaimer
Embarcadero
Visit Embarcadero
Embarcadero Community
JEDI
Links
How to display both Latin and Greek characters in a TRichEdit Turn on/off line numbers in source code. Switch to Orginial background IDE or DSP color Comment or reply to this aritlce/tip for discussion. Bookmark this article to my favorite article(s). Print this article
12-Oct-02
Category
Reporting /Printing
Language
Delphi 2.x
Views
59
User Rating
No Votes
# Votes
0
Replies
0
Publisher:
DSP, Administrator
Reference URL:
DKB
			Author: Jonas Bilinkevicius

I am trying to display some results in a TRichEdit control. The text is a mixture 
of Latin letters and Greek (science) letters. Obviously, I have to change the font 
to 'Symbol' when I want to display the greek letter, otherwise it will be the 
default font. So, how do I do that? For example how do I display in RichEdit box 
the following:
RichEdit1.Lines.Add('Standard deviation /* here I want to insert the Greek letter 
'sigma' */ is '+FloatToStr(sigma));

Answer:

The key is to not use Lines.Add to add the text, the Lines property is not 
"formatting-aware". You do it this way:

1   { ... }
2   const
3     norm_font = 'Times New Roman';
4     norm_charset = DEFAULT_CHARSET;
5     symb_font = 'Symbol';
6     symb_charset = SYMBOL_CHARSET;
7     { ... }
8   
9   with richedit1 do
10  begin
11    selstart := gettextlen; {set caret to end}
12    selattributes.Name := norm_font;
13    selattributes.charset := norm_charset;
14    seltext := 'Standard deviation ';
15    selattributes.Name := symb_font;
16    selattributes.charset := symb_charset;
17    seltext := 'S';
18    selattributes.Name := norm_font;
19    selattributes.charset := norm_charset;
20    seltext := ' is ' + FloatToStr(sigma);
21    { etc. }
22  end;


As you see this is quite cumbersome but the alternative is even more so: constructing a *complete* rich text file (with font table!) for the text to insert and use EM_STREAMIN to get it into the text.

			
Vote: How useful do you find this Article/Tip?
Bad Excellent
1 2 3 4 5 6 7 8 9 10

 

Advertisement
Share this page
Advertisement
Download from Google

Copyright © Mendozi Enterprises LLC