Solved

assigning FONT in richedit

Posted on 2002-06-19
6
437 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
ScreenConnect 6.0 Free Trial

Discover new time-saving features in one game-changing release, ScreenConnect 6.0, based on partner feedback. New features include a redesigned UI, app configurations and chat acknowledgement to improve customer engagement!

 

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

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
delphi exception 7 64
error 1.1 400 Bad request idhttp delphi 18 92
SUM 2 INTEGER ARRAYS INTO 1 10 101
how can i search if string exist in array ? 3 59
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
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…
Microsoft Active Directory, the widely used IT infrastructure, is known for its high risk of credential theft. The best way to test your Active Directory’s vulnerabilities to pass-the-ticket, pass-the-hash, privilege escalation, and malware attacks …

832 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