Different colored text

I need to show text in paragraph format in a window within my main program. I thought of using a multiline edit control, but I also need to be able to change the color of some of the words within the paragraph. The user will not be editing the text, just scrolling through and reading it. What is the best way to accomplish this?

Comments

: I need to show text in paragraph format in a window within my main program. I thought of using a multiline edit control, but I also need to be able to change the color of some of the words within the paragraph. The user will not be editing the text, just scrolling through and reading it. What is the best way to accomplish this?: I would use the TRichEdit. Write the text using your favorite word processor (such as word) and save it as an .rtf file. This you can load into the TRichEdit during design-time or runtime (as needed or wished). Make sure to set the ReadOnly property to true.

: : I need to show text in paragraph format in a window within my main program. I thought of using a multiline edit control, but I also need to be able to change the color of some of the words within the paragraph. The user will not be editing the text, just scrolling through and reading it. What is the best way to accomplish this?: : : I would use the TRichEdit. Write the text using your favorite word processor (such as word) and save it as an .rtf file. This you can load into the TRichEdit during design-time or runtime (as needed or wished). Make sure to set the ReadOnly property to true.: I'm not familiar with TRichEdit. Also, the text that will be displayed is dynamic. The program is for computer interviewing and so the text that is shown can and does change quite often.

: : : I need to show text in paragraph format in a window within my main program. I thought of using a multiline edit control, but I also need to be able to change the color of some of the words within the paragraph. The user will not be editing the text, just scrolling through and reading it. What is the best way to accomplish this?: : : : : I would use the TRichEdit. Write the text using your favorite word processor (such as word) and save it as an .rtf file. This you can load into the TRichEdit during design-time or runtime (as needed or wished). Make sure to set the ReadOnly property to true.: : : I'm not familiar with TRichEdit. Also, the text that will be displayed is dynamic. The program is for computer interviewing and so the text that is shown can and does change quite often.

: : : : I need to show text in paragraph format in a window within my main program. I thought of using a multiline edit control, but I also need to be able to change the color of some of the words within the paragraph. The user will not be editing the text, just scrolling through and reading it. What is the best way to accomplish this?: : : : : : : I would use the TRichEdit. Write the text using your favorite word processor (such as word) and save it as an .rtf file. This you can load into the TRichEdit during design-time or runtime (as needed or wished). Make sure to set the ReadOnly property to true.: : : : : I'm not familiar with TRichEdit. Also, the text that will be displayed is dynamic. The program is for computer interviewing and so the text that is shown can and does change quite often.: : : You might try this...: Place a TRichEdit on the form and insert this: [code]: procedure ChangeText(re:TRichEdit; Word :string; fName:string;: aColor:TColor; aSize:integer; fIndent:integer;aStyle: TFontStyles);: .....: : procedure TForm1.ChangeText(re:TRichEdit; Word :string;: fName:string; aColor:TColor; aSize:integer; fIndent:integer;: aStyle: TFontStyles);: var: cp, cp2: Integer;: begin: cp := 0;: with re do begin: repeat: cp2 := FindText(Word, cp,length(lines.Text), [stWholeWord]);: cp := cp2+1;: SelStart := cp2;: SelLength:=Length(Word);: SelAttributes.Color:=aColor;: SelAttributes.Name:=fName;: SelAttributes.Style:=aStyle;: SelAttributes.Size:=aSize;: Paragraph.FirstIndent := fIndent;: until: cp = 0;: end;: end;: [/code]: : Call it like this:: [code]: procedure TForm1.Button11Click(Sender: TObject);: begin: ChangeText(RichEdit1,'Test','Arial',clblue,16,0,[fsBold]);: end;: [/code]: : You may want to get rid of the indent, size and fontname.: There are probably better ways to do this, but this works for me.: : James: : : I will give that a try. Thanks!!