Solved

assigning FONT in richedit

Posted on 2002-06-19
6
439 Views
Last Modified: 2013-12-03
Whats wrong with my code why my richedit will not change its font when it comes with Wingdings and Marlett etc..

RichEdit1.Font.name := FontName.items[FontName.itemindex];

where [fontName] contains LIST OF FONT NAMES like

Arial
Arial Black
Wingdings
Wingding1
Wingding2
etc..
0
Comment
Question by:girlswants_me
[X]
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
6 Comments
 

Author Comment

by:girlswants_me
ID: 7094620
can you give me the exact code for it?
thank you in advance
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 100 total points
ID: 7094880
Hello

  use SelAttributes instead of Font to change the font of selected Text

  RichEdit1.SelAttributes.Name := FontName.Items[FontName.ItemIndex];
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7094881
a guess

this line
RichEdit1.Font.name := FontName.items[FontName.itemindex];
changes only the defaultattributes

if you want to change the font you must first select the whole text and apply your font to the selattributes like

richedit1.selstart := 0;
richedit1.sellength := length(Richedit1.lines.text);
//maybe there is a richedit.selectall;
richedit.selattributes.font.name := FontName.items[FontName.itemindex];

just from head, not tested

meikl ;-)
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:girlswants_me
ID: 7094966
it still dont work
0
 
LVL 27

Expert Comment

by:kretzschmar
ID: 7094974
is the font available on the system?
0
 
LVL 6

Expert Comment

by:DrDelphi
ID: 7096872
Try this:

procedure TForm1.FormCreate(Sender: TObject);
begin
 Listbox1.items:=Screen.Fonts;
end;

procedure TForm1.Button1Click(Sender: TObject);
begin
 RichEdit1.Font.name:=Listbox1.items[Listbox1.itemindex];
 RIchEdit1.Text:='DrDelphi rules';
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
 RichEdit1.Selstart:=0;
 RichEdit1.Sellength:=3;
 RichEdit1.SelAttributes.Name:=Listbox1.items[listbox1.itemindex];

end;



This works for me here, with every font that appears in the listbox. Good luck!!
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Delphi Yen format 3 59
FMX TEdit KeyUp handler detecting  "enter" key 4 37
Get weeknumber and year from date 4 26
SQL Server Express automatically execute SQL or SP 8 31
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

756 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