Browse DevX
Sign up for e-mail newsletters from DevX

Tip of the Day
Language: PowerBuilder
Expertise: Beginner
Nov 20, 1998



Building the Right Environment to Support AI, Machine Learning and Deep Learning

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.

DevX Pro
Comment and Contribute






(Maximum characters: 1200). You have 1200 characters left.



Thanks for your registration, follow us on our social networks to keep up-to-date