Solved

assigning FONT in richedit

Posted on 2002-06-19
6
435 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:
mnasman 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 

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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

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…
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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
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…

744 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

12 Experts available now in Live!

Get 1:1 Help Now