Solved

Text Color in TMEMO or other component

Posted on 2000-03-16
7
319 Views
Last Modified: 2010-04-04
How to set each word in TMEMO to many color font in one line ? I can set  to one color only. How do I  or have any component that I can use more ?
0
Comment
Question by:cristh
7 Comments
 
LVL 2

Accepted Solution

by:
aubs earned 100 total points
ID: 2624052
Use a richedit on the win32 tab.

Look in the online help how to set the font color and style, use the SelAttributes  property.

This is taken from the online help:

This example requires a TRichEdit and two TButtons. Leave the default text, usually "RichEdit1", in the lines property. The DefAttributes will apply to this text.

procedure TForm1.Button1Click(Sender: TObject);
begin
  with RichEdit1.SelAttributes do
  begin
    Color := clRed;
    Height := Height + 5;
  end;
  RichEdit1.Lines.Add('This line of text will be red.');
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
  RichEdit1.DefAttributes.Color := clBlue;
  RichEdit1.DefAttributes.Style := [fsBold, fsItalic];
end;

0
 
LVL 3

Expert Comment

by:markshiffer
ID: 2624270
aubs is right, your need require a rich edit component.
0
 
LVL 7

Expert Comment

by:RBertora
ID: 2624346
If you are using D4 or less then this is the code using a TRichedit component as suggested earlier:

    RichEditMemo.Selstart := Length(RichEditMemo.Text);
    RichEditMemo.SelAttributes.Color := clBlue;
    RichEditMemo.SelText := 'This is the first line in blue'+#10;
    RichEditMemo.Selstart := Length(RichEditMemo.Text);
    RichEditMemo.SelAttributes.Color := clBlack;
    RichEditMemo.SelText := 'This is the second line in black'+#10;

Rob;-)
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.

 
LVL 7

Expert Comment

by:RBertora
ID: 2624347
If you are using D4 or less then this is the code using a TRichedit component as suggested earlier:

    RichEditMemo.Selstart := Length(RichEditMemo.Text);
    RichEditMemo.SelAttributes.Color := clBlue;
    RichEditMemo.SelText := 'This is the first line in blue'+#10;
    RichEditMemo.Selstart := Length(RichEditMemo.Text);
    RichEditMemo.SelAttributes.Color := clBlack;
    RichEditMemo.SelText := 'This is the second line in black'+#10;

Rob;-)
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 2626973
Whay don't use TMemoColor ?
I use it and is very nice .
Regards,
Nick aka ginsonic
0
 
LVL 9

Expert Comment

by:ginsonic
ID: 2627034
This is the download address :
http://www.balticsolutions.com/
It's freeware .
Pay only if you wish the source code .

Nick
0
 

Author Comment

by:cristh
ID: 2630451
Thank aubs and I accept  your comment as answer. Thank you all for your comment :)
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

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…
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…
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…

861 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

25 Experts available now in Live!

Get 1:1 Help Now