Selection Color of TRichEdit

[ DelphiLand FAQ ]

Posted by webmaster Guido on April 06, 2004 at 15:35:35:

In Reply to: Selection Color posted by joey on April 04, 2004 at 22:52:40:

: I have looked in lots of places but cant find an answer to this question anywhere :S.

: Can i change the highlight color of TRichEdit?? from the icci black to another color ;)

You can not directly set the background highlight color nor the highlight font-color of a RichEdit's. Both colors are set automatically, they depend from the color of the RichEdit.

The RichEdit color is set by default to clWindow, Windows' color for the background of text-windows. In the "classical" setting this is white. However, in the Object Inspector or in your code, you can change the color of the RichEdit to something else, for example:

RichEdit1.Color := clYellow;

Now, the background color and font color for highlighted text will change automatically to "inverse" colors, contrasting colors that enable the user to see what is selected.
Attention: there are some exceptions, for example: a black RichEdit generates also a black highlight-background... Experiment with the colors and you'll see what works and what doesn't.

Related Articles and Replies:

[ DelphiLand: free Delphi source code, tips, tutorials ]