Solved

Text Color in TMEMO or other component

Posted on 2000-03-16
7
322 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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
When i run adoquery my application freezes 26 188
DBGrid or StringGrid ? 6 120
Delphi Seattle StructureView color 1 21
TlistView is Really heavy on Android 3 15
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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial

756 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