Rich Text Edit – Syntax Highlighting

Rich Text Edit – Syntax Highlighting

I’m building an application where the user can type several lines of text and save it to disk (as plain text). It would be nice if some words appeared in other colors for emphasis. This is something like syntax highlighting you can find in Powerbuilder itself. If I want to implement this, where should I check for these special words, and how can I adjust the properties of that text only?

To implement syntax highlighting, it’s best to use the Rich Text Edit Control. Loop through the lines of text in the control looking for the words you want to highlight.

When you have identified the text you want to highlight, use the RTE command SelectText to select the text inside the control. Then use the RTE command SetTextColor to change the color of that item of text. Be aware that the RTE supports only the basic 16 windows colors?for example, 255 for red and 127 for dark red.


Share the Post: