Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Different line colors in a Memo/RichEdit

Posted on 1999-07-26
2
Medium Priority
?
6,171 Views
Last Modified: 2013-11-22
How do I write with different colors in a Memo/Richedit? I would like to use it in the following way:

var
 str : string;
begin
  if pos('g', str) then Memo1.Lines.Add( --something green)
  if pos('r', str) then Memo1.Lines.Add( --something red)
end;

Regards

/Peter
0
Comment
Question by:volavy
[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
2 Comments
 

Accepted Solution

by:
Hamilton earned 90 total points
ID: 1391248
I'm afraid I don't exactly understand your code example. But I can provide you a procedure which adds a line to a TRichEdit in a specified color like this:

procedure AddRichLine(Rich: TRichEdit; const s: string; Color: TColor);
 var
  Posit: Integer;
 begin
  Posit := Length(Rich.Text);
  Rich.Lines.Add(s);
  Rich.SelStart := Posit;
  Rich.SelLength := Length(s);
  Rich.SelAttributes.Color := Color;
  Rich.SelLength := 0;
  Rich.SelStart := Length(Rich.Text);
 end;

If this procedure doesn't do the thing you want, please reject the answer and give me a comment on where you have your difficulties ...

Regards,
Hamilton

0
 
LVL 13

Expert Comment

by:Epsylon
ID: 1391249
In TRichEdit:

  RichEdit1.SelAttributes.Color := clGreen;
  RichEdit1.Lines.Add('I am green!');
  RichEdit1.SelAttributes.Color := clRed;
  RichEdit1.Lines.Add('I am red!');


Don't think you can use colors in a memo in a proper way.


Regards,

Epsylon.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

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

The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…
Suggested Courses

721 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