Solved

assigning FONT in richedit

Posted on 2002-06-19
6
436 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
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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…
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…

911 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

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now