DelphiFAQ Home Search:

Colored text - 'syntax highlighting' in an RTF control

 

commentsThis article has not been rated yet. After reading, feel free to leave comments and rate it.

For a simple HTML editor - let's say you want to have the text between '<' and '>' to be in
blue similar to comments in the code editor - you put some code in the RichEdit's Change
event like in the following example:

procedure TForm1.RichEdit1Change(Sender: TObject);
begin
  with richedit1 do
  begin
    if text[selstart]='<' then selattributes.color:=clblue;
    if text[selstart]='>' then selattributes.color:=clblack;
  end;
end;

Comments:

2006-05-04, 03:42:14
anonymous from Japan  
Very good idea !!! Thank you very much.

 

 

NEW: Optional: Register   Login
Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option, or post under a registered account.
 

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity.
The owner of this web site reserves the right to delete such material.

photo Add a picture: